Re-hash response caching keys to avoid persisting raw request input#3414
Merged
Re-hash response caching keys to avoid persisting raw request input#3414
Conversation
Member
Author
|
Auto-reviewed and merging on behalf of @jlowin — CI is green (Windows OAuth proxy timeouts are pre-existing flaky tests). |
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.
Motivation
Description
hashlib-backed_hash_cache_keyand three key-builder helpers:_make_call_tool_cache_key,_make_read_resource_cache_key, and_make_get_prompt_cache_key, each producing a SHA-256 hex digest of the request-derived string.ResponseCachingMiddlewareto call the new helpers fortools/call,resources/read, andprompts/getinstead of embedding raw names/arguments/URIs in keys.tests/server/middleware/test_caching.py::TestCacheKeyGeneration) to assert keys are 64-char SHA-256 hex strings, do not contain raw secret/URI fragments, and are stable across repeated calls.Testing
uv syncwhich succeeded.uv run pytest tests/server/middleware/test_caching.py) and the new unit tests passed (3 passed) and relevant integration checks for caching exercised passed (5 passed).uv run pytest -n auto) which completed but reported a small number of unrelated failures/timeouts (integration/network-related test flakes and proxy/httpx ProxyError) that are external to the key-hashing change.uv run prek run --all-files) which failed to initialize hooks due to outbound GitHub access/proxy 403 (environment network constraint), not due to lint/type errors in this change.Codex Task