Repository navigation
Conversation
requests quotes the full request URL, query string included, in its connection errors. analyze_page_speed sends the API key in that query, so an unreachable network or a refused connection returned the key in the tool error, where the model and the chat transcript see it. Catch requests.RequestException, redact the key and report the failure.
This branch has not been deployed
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.
analyze_page_speedsendspagespeed.api_keyas thekeyquery parameter. When the request fails before a response (offline, DNS, refused connection),requestsquotes the full URL in its exception text, e.g.Max retries exceeded with url: /...runPagespeed?url=...&key=<the key>. The_safewrapper returns that text as the tool error, so the key lands in the model's context and the chat transcript.This catches
requests.RequestExceptioninanalyze_page_speed, replaces the key with[redacted]and returnsPageSpeed API request failed (<ExceptionName>): .... It also means a network failure now returns a normal error dict instead of a bare exception.Tests: two new tests in
tests/test_pagespeed.pythat hit a closed local port, so the exception is the real one fromrequests. Without the fix both tests error out with the rawConnectionError, whose text containskey=test-key. Full suite: 2772 passed, 2 skipped.This is not a write tool, so the safety layer is untouched.
Found, written and tested with Claude Code; I'm responsible for it.