fix: Expand sanitizeURL secrets redactions#4126
Conversation
- 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.
req.GetBody in NewRequest and expand sanitizeURL secrets redactions
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
gmlewis
left a comment
There was a problem hiding this comment.
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
|
@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. |
stevehipwell
left a comment
There was a problem hiding this comment.
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"?
|
Thanks for catching this. Dropping the GetBody change as the standard library already handles it correctly. |
|
@YooLCD why did you make the change in the first place? |
|
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. |
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. |
|
Please update the PR description accordingly. |
|
Updated the PR description to reflect the remaining change only. |
req.GetBody in NewRequest and expand sanitizeURL secrets redactionssanitizeURL secrets redactions
|
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. |
|
@stevehipwell and @alexandear - are all your concerns addressed and this can be merged? |
gmlewis
left a comment
There was a problem hiding this comment.
Thank you, all!
LGTM.
Merging.
Expand
sanitizeURLto coveraccess_tokenandtokenOnly
client_secretwas being redacted.access_tokenandtokenare equallysensitive and can appear in query parameters, leaking into error logs via
url.Error.