UID2-7505: Point v2 envelope error responses to encryption/decryption docs#2657
Open
sunnywu wants to merge 1 commit into
Open
UID2-7505: Point v2 envelope error responses to encryption/decryption docs#2657sunnywu wants to merge 1 commit into
sunnywu wants to merge 1 commit into
Conversation
… docs
The v2 request-envelope parse errors ("Version mismatch", "Body too
short", "Check encryption key") gave callers no hint that the body must
be an encrypted request envelope rather than base64-encoded plain JSON.
Private Operator customers hitting the endpoint with a raw curl call
(base64 of JSON) repeatedly got the opaque "Invalid body: Version
mismatch." and mistook it for a server-side bug.
Append a hint to these three envelope errors explaining that the body
must be encrypted and linking to the encryption/decryption code
examples. The leading machine-readable phrase is preserved so any
downstream pattern-matching is unaffected.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Ticket: UID2-7505
Branch: syw-UID2-7505-descriptive-envelope-errors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes the v2 request-envelope parse errors in
V2RequestUtilself-explanatory so callers who send an unencrypted body (e.g. a rawcurlrequest with base64-encoded JSON) understand that the body must be an encrypted request envelope.Private Operator customers repeatedly call
/v2/token/generatedirectly with:Because the body is base64 of plain JSON (not an encrypted v2 envelope), byte 0 fails the version check and the operator returns the opaque:
Nothing in that message tells the caller the real problem is that the payload must be encrypted. In a recent support thread this caused days of back-and-forth — the customer kept re-running curl-with-base64 tests, got "Version mismatch" each time, and mistook it for a server-side bug.
Change
Appends a hint to the three envelope-parse errors that fire when the body is not a valid encrypted envelope:
Invalid body: Body too short. Check encryption method.Invalid body: Version mismatch.Invalid body: Check encryption key (ClientSecret)The hint tells the caller the body must be an encrypted request envelope (base64-encoding JSON is not enough) and links to https://unifiedid.com/docs/getting-started/gs-encryption-decryption#encryption-and-decryption-code-examples.
The existing leading phrase of each message is preserved, so any downstream code that pattern-matches on the current text is unaffected.
Testing
testParseRequestWithTooShortBodyto assert the leading phrase (viastartsWith) plus the presence of the docs link.testParseRequestWithVersionMismatch, which feeds base64 of plain JSON (the exact curl failure mode) and asserts both the preservedInvalid body: Version mismatch.prefix and the docs link.mvn -Dtest=V2RequestUtilTest test→Tests run: 7, Failures: 0, Errors: 0.Jira
UID2-7505
🤖 Generated with Claude Code