Skip to content

Go SDK: a decrypt error names the Go type of the decrypted value ("opened as string, not int64") #2007

In review

Description

@coderdan

Background

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

  1. 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").
  2. Update the tests that pin the old text, and add one asserting that the message names no decrypted kind.
  3. Add a languages/golang/CHANGELOG.md entry.

Relationship to other work

Activity

  1. added
    bug
    Golang
    on Nov 27, 2026
  2. self-assigned this
    on Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

GolangSDKbug

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions