Skip to content

test(auth): verify malformed JSON array payloads do not crash credentials parser#16156

Merged
scotthart merged 1 commit into
googleapis:mainfrom
westarle:fix-json-crash
Jun 12, 2026
Merged

test(auth): verify malformed JSON array payloads do not crash credentials parser#16156
scotthart merged 1 commit into
googleapis:mainfrom
westarle:fix-json-crash

Conversation

@westarle

Copy link
Copy Markdown
Contributor

nlohmann::json library safely returns .end() on non-object types. Added this test to explicitly verify and enforce this type-safe behavior moving forward.

…ials parser

The C++ test sufficiency gap report originally assumed that calling `.find()` on an array payload would crash the parser. However, the `nlohmann::json` library safely returns `.end()` on non-object types. Added this test to explicitly verify and enforce this type-safe behavior moving forward without needing redundant production code checks.
@westarle westarle requested a review from a team as a code owner June 12, 2026 16:05

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

Copy link
Copy Markdown

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 adds a test case to ComputeEngineCredentialsTest.ParseMetadataServerResponse to verify the behavior when parsing an empty JSON array. There are no review comments, and I have no feedback to provide.

@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.20%. Comparing base (e908d88) to head (330ff01).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16156      +/-   ##
==========================================
- Coverage   92.20%   92.20%   -0.01%     
==========================================
  Files        2264     2264              
  Lines      209084   209084              
==========================================
- Hits       192791   192786       -5     
- Misses      16293    16298       +5     

☔ 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.

@scotthart scotthart merged commit ce5aa34 into googleapis:main Jun 12, 2026
60 of 66 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.

3 participants