Skip to content

[CLEAN] Synthetic Benchmark PR #20177 - fix(prefect-gcp): prevent double-nesting in GcsBucket._resolve_path#558

Open
tomerqodo wants to merge 5 commits intobase_pr_20177_20260121_2626from
clean_pr_20177_20260121_2626
Open

[CLEAN] Synthetic Benchmark PR #20177 - fix(prefect-gcp): prevent double-nesting in GcsBucket._resolve_path#558
tomerqodo wants to merge 5 commits intobase_pr_20177_20260121_2626from
clean_pr_20177_20260121_2626

Conversation

@tomerqodo
Copy link

Benchmark PR PrefectHQ#20177

Type: Clean (correct implementation)

Original PR Title: fix(prefect-gcp): prevent double-nesting in GcsBucket._resolve_path
Original PR Description: closes PrefectHQ#20174

this pr fixes the GcsBucket._resolve_path double-nesting bug that occurs when storage_block_id is null (e.g., when context is serialized to remote workers like Ray).

changes

  • add duplicate-prefix check in _resolve_path() to prevent double-nesting when path already starts with bucket_folder
  • add regression test for the fix
  • fix test_push_to_gcs fixture that had broken .prefectignore patterns due to leading whitespace
  • add filterwarnings for upstream deprecation warnings (httplib2, pathspec, google.api_core, coolname)
  • increase test harness timeout to 60s to fix CI flakiness on Python 3.11+ (see Unit tests randomly fail to connect to ephemeral Prefect API server PrefectHQ/prefect#16397)

prior art

this is the same fix that was applied to _join_bucket_folder in PrefectHQ#18237 - the _resolve_path method had the same bug but wasn't fixed at that time.

reproduction script
from prefect_gcp.cloud_storage import GcsBucket

bucket = GcsBucket(bucket="test-bucket", bucket_folder="results/")

# simulate what happens when storage_block_id is null:
# create_result_record() adds bucket_folder to storage_key
already_prefixed_path = "results/abc123"

# before fix: returns "results/results/abc123" (double-nested)
# after fix: returns "results/abc123" (correct)
result = bucket._resolve_path(already_prefixed_path)
print(f"Result: {result}")
assert not result.startswith("results/results/"), f"Double nesting detected: {result}"

🤖 Generated with Claude Code
Original PR URL: PrefectHQ#20177

zzstoatzz and others added 5 commits January 21, 2026 15:46
When storage_block_id is null (e.g., context serialized to Ray workers),
create_result_record() adds bucket_folder to storage_key via _resolve_path.
Then write_path() calls _resolve_path again, causing double-nested paths
like "results/results/abc123" instead of "results/abc123".

Add duplicate-prefix check to _resolve_path, matching the existing check
in _join_bucket_folder.

Fixes PrefectHQ#20174

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- fix .prefectignore content in test fixture (remove leading whitespace)
- add filterwarnings to pyproject.toml to suppress upstream deprecation warnings

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
remove extra disable_logging fixture and temporary_settings wrapper
to match pattern used by prefect-aws and other integrations

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
fixes ephemeral server startup timeouts on Python 3.11+ with xdist workers
see PrefectHQ#16397

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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