google / google/adk-python

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

Đang mở
#6,881 3 bình luận 0 reaction 1 người được giao Được @sanketpatil06 nhận Xem trên GitHub
eval
Ngôn ngữ chính
Python
Star
21.5k
Fork
4k
Merge trung bình
1 ngày 14 giờ
Pull request đã merge (30 ngày)
37

Mô tả

### Description

`create_gcs_eval_managers_from_uri()` in [`[src/google/adk/cli/utils/evals.py]`](https://github.com/google/adk-python/blob/main/src/google/adk/cli/utils/evals.py) has a docstring that says:

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

But the implementation never extracts a bucket from a path; it treats everything after `gs://` as the literal bucket name:

```python
if eval_storage_uri.startswith('gs://'):
gcs_bucket = eval_storage_uri.split('://')[1]
```

`'gs://my-bucket/some/path'.split('://')[1]` returns `'my-bucket/some/path'`, slashes included, not `'my-bucket'`.

### Repro

```python
from google.adk.cli.utils.evals import create_gcs_eval_managers_from_uri

create_gcs_eval_managers_from_uri("gs://my-bucket/some/path")
```

### Expected behavior

Per the docstring, this should extract `my-bucket` as the bucket name and (presumably) use `some/path` as a prefix/subdirectory for eval storage.

### Actual behavior

`gcs_bucket` ends up as the literal string `"my-bucket/some/path"`. This is passed straight into both `GcsEvalSetsManager` and `GcsEvalSetResultsManager`:

```python
self.bucket = self.storage_client.bucket(self.bucket_name)
if not self.bucket.exists():
raise ValueError(f"Bucket `{self.bucket_name}` does not exist...")
```

`storage_client.bucket(name)` doesn't validate the name locally, so this only fails later at `.exists()`, which 404s because GCS bucket names can never contain `/`. The resulting error —

```
ValueError: Bucket `my-bucket/some/path` does not exist. Please create it before using the GcsEvalSetsManager.
```

— is misleading: the real bucket (`my-bucket`) may well exist; the tool just built an invalid bucket name from the path segment.

### Additional note

Even if bucket extraction were implemented, the path portion currently has nowhere to go — `_get_eval_history_dir()` / `_get_eval_sets_dir()` hard-code `{app_name}/evals/eval_history` and `{app_name}/evals/eval_sets` respectively, with no support for a custom prefix within the bucket.

### Environment

- `google-adk` version: 2.0.0 (confirmed still present on `main` as of 2026-08-24)
- Reproduced in both `GcsEvalSetsManager` and `GcsEvalSetResultsManager`

### Suggested fix
- Implement the extraction the docstring promises (e.g. `eval_storage_uri.split('://')[1].split('/')[0]` for the bucket, with the remainder threaded through as a storage prefix), or

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.