fix: follow redirects when downloading skills in GcpSkillRegistry - #6824
Open
codebee-aoki wants to merge 1 commit into
Open
fix: follow redirects when downloading skills in GcpSkillRegistry#6824codebee-aoki wants to merge 1 commit into
codebee-aoki wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Author
|
@googlebot I signed it! |
The Agent Registry media download endpoint (alt=media) responds with a 302 redirect to a short-lived GCS signed URL instead of streaming the archive directly. httpx does not follow redirects by default and its raise_for_status() raises on 3xx responses, so _make_request treated the 302 as a failure and get_skill() could never download the skill archive. Following redirects is safe here: httpx drops the Authorization header on cross-origin redirects, so the OAuth token is not forwarded to the signed-URL host (GCS would reject a signed URL carrying extra credentials anyway).
codebee-aoki
force-pushed
the
fix/gcp-skill-registry-follow-redirects
branch
from
August 20, 2026 06:43
d22bc84 to
0cb0ca7
Compare
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.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
2. Or, if no issue exists, describe the change:
Problem:
GcpSkillRegistry.get_skill()fails when downloading the skill archive. The Agent Registry API serves the revision media download (?alt=media) as a302redirect to a GCS signed URL. Thehttpx.AsyncClientcreated in_create_httpx_clientdoes not follow redirects (httpx default), andresponse.raise_for_status()raises on 3xx, so the request surfaces asRuntimeError: API request failed with status 302: ....Solution:
Pass
follow_redirects=Trueto bothhttpx.AsyncClientconstructions in_create_httpx_client(the plain client and the mTLS/ssl-context client).Following redirects is safe here: httpx removes the
Authorizationheader when following a redirect to a different origin, so the OAuth bearer token is not leaked to the GCS signed-URL host (GCS would reject a signed URL carrying extra credentials anyway).Testing Plan
Unit Tests:
Added a unit test (
test_create_httpx_client_follows_redirects) asserting that clients created by_create_httpx_clienthavefollow_redirects=True, for both the default branch and the mTLS/ssl-context branch. Also updated an existing assertion (test_get_skill_with_mtls) that checked the exacthttpx.AsyncClientconstructor kwargs, since it now includesfollow_redirects=True.Manual End-to-End (E2E) Tests:
Tested end-to-end by applying the identical change (monkey-patching
GCPSkillRegistry._create_httpx_clientto passfollow_redirects=True, same two-branch logic as this PR) to an agent deployed on Agent Engine runtime. Confirmed that skill downloads from the Agent Registry — which previously failed withRuntimeError: API request failed with status 302: ...— now succeed: the?alt=mediarequest's 302 redirect to the GCS signed URL is followed and the skill archive is downloaded and loaded correctly.Checklist
Additional context
None.