PSPC-SPAC-buyandsell / von_agent

VON agents using indy-sdk
Apache License 2.0
5 stars 12 forks source link

create_cred encodes null values as string 'None' #11

Closed nrempel closed 6 years ago

nrempel commented 6 years ago

It seems that sending null values to create_cred results in those claims containing the string value 'None'. Is it possible to encode these as null?

https://github.com/PSPC-SPAC-buyandsell/von_agent/blob/master/von_agent/agents.py#L1065

sklump commented 6 years ago

Indy-sdk throws a CommonInvalidStructure on a raw value that is not a string.

The raw value is just a noise as far as indy-sdk is concerned. The encoded value is the authoritative payload, and the way to get its true original corresponding raw value is codec.decode().

nrempel commented 6 years ago

Ok, good to know. Thanks.

nrempel commented 6 years ago

Can you modify cred_attr_value to encode None values as an empty string instead of the string 'None'?

https://github.com/PSPC-SPAC-buyandsell/von_agent/blob/master/von_agent/codec.py#L101

>>> str(None) == 'None'
True
sklump commented 6 years ago

Sure, I can do that for the next release.

But the Right Thing is to use util.decode() on the encoded value. Otherwise you cannot tell between None and its sentinel. For that matter, the Right Thing is always to use util.decode(), otherwise you will not be able to tell between numbers and numeric strings, among other things.