You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Go SDK: a decrypt error names the Go type of the decrypted value ("opened as string, not int64") #2007
The Go SDK's generated code reads each decrypted field into the struct field's Go type, through encrypt/gensupport (convert.go). When the decrypted value cannot be read into that type, gensupport returns an error built by mismatch(v, want).
Problem
mismatch (languages/golang/encrypt/gensupport/convert.go, about line 293) writes fmt.Errorf("opened as %T, not %T", v, want). The first %T is the Go type of the decrypted value, such as string, int64 or <nil>. That type comes from the plaintext's type tag, which sits inside the encrypted envelope. So an error, which may be logged, shows what kind of value a sealed field held in that row, including whether it was a null. It is called from about ten places in convert.go.
#2005 sets the rule for the engine: an error may name a value's kind only where the kind is visible without decrypting, meaning input the caller sent or the stored record's own structure. It never names what a decrypted value opened as. #2006 applies the same rule to the Go messages it changes (O2 and GetDocument). mismatch is older and was left alone there.
Verified: by reading the code on next. Not checked: whether any caller logs these errors by default.
Proposal
Change mismatch to name only the target type: for example, the stored value does not read as a %T, as outOfRange already does ("the stored value does not fit a %T").
Update the tests that pin the old text, and add one asserting that the message names no decrypted kind.
Activity