Skip to content

fix(evals): extract bucket name from eval_storage_uri when a path is given - #6882

Closed
chelsealong wants to merge 1 commit into
google:mainfrom
chelsealong:fix-6881-gcs-eval-bucket-path-extraction
Closed

chelsealong wants to merge 1 commit into
google:mainfrom
chelsealong:fix-6881-gcs-eval-bucket-path-extraction

Conversation

@chelsealong

Copy link
Copy Markdown
Contributor

Fixes #6881

Problem

create_gcs_eval_managers_from_uri()'s docstring says:

eval_storage_uri: The evals storage URI to use. Supported URIs: gs://<bucket name>. If a path is provided, the bucket will be extracted.

But the implementation never extracted a bucket from a path — it treated
everything after gs:// as the literal bucket name:

gcs_bucket = eval_storage_uri.split('://')[1]

gs://my-bucket/some/path produced the invalid bucket name
my-bucket/some/path (slashes included), which is then passed to
GcsEvalSetsManager/GcsEvalSetResultsManager and fails later with a
misleading "bucket does not exist" error, even when my-bucket itself
exists.

Fix

Split off the first path segment so only the bucket name is used:

gcs_bucket = eval_storage_uri.split('://')[1].split('/')[0]

This matches the docstring's documented behavior for gs://<bucket name>
URIs. As noted in the issue, threading the remaining path through as a
storage prefix is a separate, larger change (the eval history/sets
directory helpers currently hard-code their paths) and is left out of this
minimal fix.

Testing plan

Added test_create_gcs_eval_managers_from_uri_extracts_bucket_from_path to
tests/unittests/cli/utils/test_evals.py, asserting that
gs://test-bucket/some/path results in GcsEvalSetsManager and
GcsEvalSetResultsManager being constructed with bucket_name='test-bucket'.

Confirmed the new test fails against the old code:

FAILED tests/unittests/cli/utils/test_evals.py::test_create_gcs_eval_managers_from_uri_extracts_bucket_from_path - AssertionError: expected call not found.
Expected: GcsEvalSetsManager(bucket_name='test-bucket', project='test-project')
  Actual: GcsEvalSetsManager(bucket_name='test-bucket/some/path', project='test-project')

And passes with the fix, along with the full existing suite for this module:

$ pytest tests/unittests/cli/utils/ -q
421 passed, 2 xfailed, 143 warnings in 17.90s

Also verified pyink --check and isort --check are clean on both changed
files.

AI disclosure

This change was authored with the assistance of an AI coding agent (Claude),
with the diff reviewed before submission.

…given

create_gcs_eval_managers_from_uri() treated everything after `gs://` as
the literal bucket name, so `gs://my-bucket/some/path` produced the
invalid bucket name `my-bucket/some/path`, contradicting the docstring
which says the bucket will be extracted if a path is provided.

Fixes google#6881
@adk-bot

adk-bot commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

Thank you @chelsealong for your contribution! 🎉

Your changes have been successfully imported and merged via Copybara in commit 490cfd7.

Closing this PR as the changes are now in the main branch.

@adk-bot adk-bot added the merged [Status] This PR is merged label Oct 2, 2026
@adk-bot adk-bot closed this Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged [Status] This PR is merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

create_gcs_eval_managers_from_uri doesn't extract bucket from path, contradicting its own docstring

3 participants