Skip to content

fix: Expand sanitizeURL secrets redactions#4126

Merged
gmlewis merged 7 commits intogoogle:masterfrom
YooLCD:fix/request-body-retry-and-sanitize-url
Apr 3, 2026
Merged

fix: Expand sanitizeURL secrets redactions#4126
gmlewis merged 7 commits intogoogle:masterfrom
YooLCD:fix/request-body-retry-and-sanitize-url

Conversation

@YooLCD
Copy link
Copy Markdown
Contributor

@YooLCD YooLCD commented Apr 2, 2026

Expand sanitizeURL to cover access_token and token

Only client_secret was being redacted. access_token and token are equally
sensitive and can appear in query parameters, leaking into error logs via url.Error.

- Set req.GetBody in NewRequest so that rate-limit retries can
  re-read the request body on POST/PUT/PATCH requests.
- Extend sanitizeURL to redact access_token and token query
  parameters in addition to client_secret.
@gmlewis gmlewis changed the title fix: set GetBody in NewRequest and expand sanitizeURL redaction fix: Set req.GetBody in NewRequest and expand sanitizeURL secrets redactions Apr 2, 2026
@gmlewis gmlewis added the NeedsReview PR is awaiting a review before merging. label Apr 2, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.74%. Comparing base (f293a76) to head (3b41c36).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4126      +/-   ##
==========================================
+ Coverage   93.72%   93.74%   +0.02%     
==========================================
  Files         211      211              
  Lines       19621    19685      +64     
==========================================
+ Hits        18389    18453      +64     
  Misses       1034     1034              
  Partials      198      198              

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Copy Markdown
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

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

This looks great, @YooLCD... thank you!
Awaiting second LGTM+Approval from any other contributor to this repo before merging.

cc: @stevehipwell - @alexandear - @zyfy29 - @Not-Dhananjay-Mishra - @munlicode

@stevehipwell
Copy link
Copy Markdown
Contributor

@YooLCD you've just overwritten the changes in your first commit with your second commit!?

@YooLCD
Copy link
Copy Markdown
Contributor Author

YooLCD commented Apr 2, 2026

@YooLCD you've just overwritten the changes in your first commit with your second commit!?

Sorry, that was my mistake. Restored in the latest commit.

Copy link
Copy Markdown
Contributor

@stevehipwell stevehipwell left a comment

Choose a reason for hiding this comment

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

I'm not sure I follow why this code is required? The existing code was working correctly as the standard library handles setting req.GetBody. I can't see any value in adding this code to make it "explicit"?

@YooLCD
Copy link
Copy Markdown
Contributor Author

YooLCD commented Apr 2, 2026

Thanks for catching this. Dropping the GetBody change as the standard library already handles it correctly.

@stevehipwell
Copy link
Copy Markdown
Contributor

@YooLCD why did you make the change in the first place?

@YooLCD
Copy link
Copy Markdown
Contributor Author

YooLCD commented Apr 2, 2026

I incorrectly assumed the body would be empty on retry. After investigation, Go's http.Client handles it correctly via GetBody. Sorry for the noise.

@alexandear
Copy link
Copy Markdown
Contributor

@YooLCD why did you make the change in the first place?

Because this PR was made by an AI agent, and it sometimes hallucinates.

@stevehipwell
Copy link
Copy Markdown
Contributor

Because this PR was made by an AI agent, and it sometimes hallucinates.

@alexandear I wasn't sure if that was a question we were permitted to ask.

@gmlewis
Copy link
Copy Markdown
Collaborator

gmlewis commented Apr 2, 2026

Please update the PR description accordingly.

@YooLCD
Copy link
Copy Markdown
Contributor Author

YooLCD commented Apr 2, 2026

Updated the PR description to reflect the remaining change only.
I also want to sincerely apologize for the confusion caused by the GetBody change — I submitted it without sufficient verification and it turned out to be unnecessary. I'm sorry for the noise.

@gmlewis gmlewis changed the title fix: Set req.GetBody in NewRequest and expand sanitizeURL secrets redactions fix: Expand sanitizeURL secrets redactions Apr 2, 2026
@gmlewis
Copy link
Copy Markdown
Collaborator

gmlewis commented Apr 2, 2026

Thank you, @alexandear and @stevehipwell for performing a deep analysis of this PR which I unfortunately neglected to do.

Previously, I relied perhaps too heavily on users reporting issues and providing solutions, often assuming these were factual accounts of problems they encountered.

In the age of AI, it is becoming increasingly apparent that agents can generate incredibly well-written descriptions of issues and accompanying solutions. This makes it challenging to distinguish genuine problems from convincing AI-generated ones.

@gmlewis
Copy link
Copy Markdown
Collaborator

gmlewis commented Apr 2, 2026

@stevehipwell and @alexandear - are all your concerns addressed and this can be merged?

Copy link
Copy Markdown
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

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

Thank you, all!
LGTM.
Merging.

@gmlewis gmlewis removed the NeedsReview PR is awaiting a review before merging. label Apr 3, 2026
@gmlewis gmlewis merged commit 96a3651 into google:master Apr 3, 2026
8 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.

4 participants