Skip to content

Go SDK: an opaque value's decrypt error, and an out-of-range integer's, still say something about the decrypted value #2008

Backlog

Description

@coderdan

Background

The Go SDK reads each decrypted field into the program's Go type through encrypt/gensupport. #2005 and #2006 set a rule for errors: 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. The type tag sits inside the encrypted envelope, and errors are often logged.

Problem

Two decrypt errors still say something about the decrypted value:

  1. An opaque value. gensupport's Opaque wraps the error from vcffi.UnmarshalStorage with %w. That error's text names the kind it found and where, for a decrypted opaque value. Removing the text while keeping errors.Is(err, ErrStorageVersion) working needs a small wrapper type.
  2. An integer out of range. outOfRange writes "the stored value does not fit a %T". It names only the target type, but it says the decrypted number is outside that type's range, which tells a reader something about the value's size.

Verified: both by reading the code on #2006's branch. Not checked: whether a caller logs these errors by default.

Proposal

  1. For Opaque, wrap the storage error in a type whose Error() names only the field and the target type, and whose Unwrap keeps errors.Is(err, ErrStorageVersion) working. Add a test that the message names no kind.
  2. For outOfRange, decide whether "does not fit" is acceptable. If not, merge it with the plain "does not open as %T" refusal. A test should pin whichever wording is chosen.

Relationship to other work

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    GolangSDKbug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions