Skip to content

fix: follow redirects when downloading skills in GcpSkillRegistry - #6824

Open
codebee-aoki wants to merge 1 commit into
google:mainfrom
codebee-aoki:fix/gcp-skill-registry-follow-redirects
Open

fix: follow redirects when downloading skills in GcpSkillRegistry#6824
codebee-aoki wants to merge 1 commit into
google:mainfrom
codebee-aoki:fix/gcp-skill-registry-follow-redirects

Conversation

@codebee-aoki

@codebee-aoki codebee-aoki commented Aug 20, 2026

Copy link
Copy Markdown

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):

  • Closes: N/A
  • Related: N/A

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 a 302 redirect to a GCS signed URL. The httpx.AsyncClient created in _create_httpx_client does not follow redirects (httpx default), and response.raise_for_status() raises on 3xx, so the request surfaces as RuntimeError: API request failed with status 302: ....

Solution:
Pass follow_redirects=True to both httpx.AsyncClient constructions in _create_httpx_client (the plain client and the mTLS/ssl-context client).

Following redirects is safe here: httpx removes the Authorization header 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:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

Added a unit test (test_create_httpx_client_follows_redirects) asserting that clients created by _create_httpx_client have follow_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 exact httpx.AsyncClient constructor kwargs, since it now includes follow_redirects=True.

$ pytest tests/unittests/integrations/skill_registry/test_gcp_skill_registry.py -q
23 passed in 3.58s

Manual End-to-End (E2E) Tests:

Tested end-to-end by applying the identical change (monkey-patching GCPSkillRegistry._create_httpx_client to pass follow_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 with RuntimeError: API request failed with status 302: ... — now succeed: the ?alt=media request's 302 redirect to the GCS signed URL is followed and the skill archive is downloaded and loaded correctly.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

Additional context

None.

@google-cla

google-cla Bot commented Aug 20, 2026

Copy link
Copy Markdown

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.

@codebee-aoki

Copy link
Copy Markdown
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
codebee-aoki force-pushed the fix/gcp-skill-registry-follow-redirects branch from d22bc84 to 0cb0ca7 Compare August 20, 2026 06:43
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.

2 participants