Skip to content

fix(types): reject non-string Any JSON fallback payloads - #498

Merged
iainmcgin merged 5 commits into
anthropics:mainfrom
zayedu:codex/fix-any-json-fallback
Oct 2, 2026
Merged

iainmcgin merged 5 commits into
anthropics:mainfrom
zayedu:codex/fix-any-json-fallback

Conversation

@zayedu

@zayedu zayedu commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Unregistered Any type URLs currently accept object, array, number, and boolean value payloads and silently replace them with empty bytes. Return a descriptive deserialization error for these malformed inputs so payload data cannot disappear unnoticed.

Missing, null, and empty-string payloads retain their existing empty-byte behavior. Valid base64 strings and registered-type decoding are unchanged. Regression tests cover both a missing registry and an installed registry without the requested type, including valid and invalid base64 controls.

Fixes #487.

Validation:

  • task lint
  • task test (with repository-pinned protoc 33.5)
  • cargo test -p buffa-types --features json fallback_base64
  • Both required Rust review agents reported no findings.

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@zayedu

zayedu commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@zayedu

zayedu commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

recheck

github-actions Bot added a commit that referenced this pull request Oct 1, 2026
@zayedu

zayedu commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

@iainmcgin Could you review this fix for #487? It rejects non-string Any JSON fallback payloads and adds regression coverage for both registry states. Local lint and workspace tests passed.

zayedu and others added 4 commits October 1, 2026 20:44
An Any whose type has no JSON entry in the type registry parsed to an
empty payload when its JSON used the expanded form, because that path
read only the "value" key. Every key other than "@type" and "value" is
now an error there. The three errors on that path (an extra key, a
non-string "value", a string that is not base64) say whether a registry
is installed, name the type URL, and name how to register the message.

The guide documents both JSON forms of Any and the registration that
the expanded form needs.
@iainmcgin

Copy link
Copy Markdown
Collaborator

[claude code] Thanks for the fix. I pushed a merge of main and maintainer commits on top that close the neighbouring cases on the same path.

The fallback read only the value key, so the expanded form of a type with no registry entry, {"@type": ".../my.Msg", "name": "x"}, still parsed to an Any with an empty payload. Such a type now has three error exits: any key other than @type and value, a value that is not a string, and a string that is not base64. Each says has no JSON entry in the type registry or no type registry is installed, names the type URL, and says how to register it. protobuf-go and the C++ parser also fail on an Any type they cannot resolve.

One consequence: an unregistered entry in expanded form, in google.rpc.Status.details for example, fails the whole parse.

{"@type": X}, a null value and a base64 value parse as before.

@iainmcgin iainmcgin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[claude code] Approved on behalf of @iainmcgin after review; CI is 11/11 green on 1bb2c25.

@iainmcgin
iainmcgin added this pull request to the merge queue Oct 2, 2026
Merged via the queue into anthropics:main with commit e48c806 Oct 2, 2026
11 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 2, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Any JSON: non-string "value" for unregistered type URL decodes to empty

2 participants