Skip to content

fix(wkt): accept ProtoJSON Base64 variants - #7328

Merged
suzmue merged 3 commits into
googleapis:mainfrom
akasakariko:fix-issue-6714
Nov 24, 2026
Merged

suzmue merged 3 commits into
googleapis:mainfrom
akasakariko:fix-issue-6714

Conversation

@akasakariko

@akasakariko akasakariko commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Accept standard and URL-safe Base64 with or without padding when extracting BytesValue from Any
Select the decoder from the input alphabet so decoding errors describe the encoding that was used
Keep serialization in standard padded Base64 and retain validation of malformed encodings

Reproduction
Confirmed on unmodified upstream revision 07bda02 using the public Any API
The standard padded input +/8= succeeded, while +/8 failed with Invalid padding and both -_8= and -_8 failed with Invalid symbol
All four inputs now decode to the expected bytes

Regression coverage
Nine of fourteen valid-input cases failed before the fix, all fourteen now pass
Cover both alphabets, zero to two padding characters, omitted padding, empty input, and canonical reserialization
Verify that invalid characters, invalid lengths, excess or embedded padding, and nonzero trailing bits are rejected
Assert that malformed standard and URL-safe inputs report the error from the matching decoder

Verification
cargo test --locked -p google-cloud-wkt --all-features
cargo clippy --locked -p google-cloud-wkt --all-targets -- -D warnings
cargo clippy --locked -p google-cloud-wkt --profile test -- -D warnings
cargo clippy --locked --all-features --no-deps -p google-cloud-wkt -- -D warnings -D missing_docs -D clippy::exhaustive_enums
cargo fmt --check
typos
git diff --check

Fixes #6714

Accept standard and URL-safe Base64 with optional padding when
extracting BytesValue from Any

Keep standard padded serialization and reject malformed encodings
Add regression coverage for supported encodings and invalid input

Fixes googleapis#6714
@akasakariko
akasakariko requested a review from a team as a code owner October 29, 2026 09:38

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the BytesValue deserializer in src/wkt/src/wrappers.rs to accept both standard and URL-safe Base64 alphabets, with or without padding, aligning with ProtoJSON specifications. It also introduces comprehensive parameterized tests covering various valid and invalid Base64 encoding scenarios. I have no feedback to provide as the changes are well-implemented and include robust test coverage.

@suzmue suzmue left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the PR! I just have one comment on the error path.

Comment thread src/wkt/src/wrappers.rs Resolved
Use the URL-safe decoder only when the input contains '-' or '_', as in
protobuf-go, so decoding errors describe the encoding that was used

Reuse the padding-indifferent engines from base64 and cover the decoder
selection with tests for both alphabets and underscore-only input
@suzmue

suzmue commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

/gcbrun

@suzmue suzmue self-assigned this Nov 19, 2026
@codecov

codecov Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 27.77%. Comparing base (e7cd6de) to head (f64d735).

Files with missing lines Patch % Lines
src/wkt/src/wrappers.rs 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7328      +/-   ##
==========================================
- Coverage   27.77%   27.77%   -0.01%     
==========================================
  Files         177      177              
  Lines       22622    22625       +3     
==========================================
  Hits         6284     6284              
- Misses      16338    16341       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@suzmue

suzmue commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

/gcbrun

I think the failures were related to the branch being out of date. Re-running.

@suzmue
suzmue merged commit badbc74 into googleapis:main Nov 24, 2026
44 of 45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BytesValue in Any rejects unpadded and URL-safe base64

4 participants