Skip to content

fix(media): detect GCS upload URLs by hostname instead of substring - #1914

Open
Ad1th wants to merge 1 commit into
langfuse:mainfrom
Ad1th:fix/gcs-upload-host-check
Open

Ad1th wants to merge 1 commit into
langfuse:mainfrom
Ad1th:fix/gcs-upload-host-check

Conversation

@Ad1th

@Ad1th Ad1th commented Sep 30, 2026 •

Copy link
Copy Markdown

Closes #1913

What

MediaManager._process_upload_media_job detected GCS upload targets with "storage.googleapis.com" in upload_url. That matches anywhere in the URL, so a non-GCS URL containing the string (in a query parameter, or as a prefix of another domain) was treated as GCS and sent without the x-ms-blob-type / x-amz-checksum-sha256 headers.

Change

Parse the URL and treat it as GCS only when the hostname is storage.googleapis.com or ends with .storage.googleapis.com. Behaviour for real GCS URLs is unchanged.

Tests

Added test_media_upload_gcs_detection_uses_url_host (parametrized) in tests/unit/test_media_manager.py: real GCS URLs (path-style and bucket subdomain) and non-GCS URLs with the string in the query or as a domain prefix. The two spoofed cases fail before the change and pass after.

  • pytest tests/unit/test_media_manager.py: 19 passed
  • ruff check: clean
  • Full tests/unit shows 18 errors in test_prompt.py; they are identical on main without this change.

RetriggerConfidence Score: 5/5

The PR appears safe to merge; no actionable regression was established.

Summary

The PR changes GCS upload detection from a substring check to a hostname check.

  • Genuine GCS hosts continue to omit the Azure and S3 upload headers.
  • URLs that mention the GCS hostname only in a query string or as a domain prefix no longer receive GCS treatment.
  • Parametrized tests cover both behaviors.

Reviews (1) · Last reviewed commit: "fix(media): detect GCS upload URLs by ho..."

Verification

uv run --frozen pytest tests/unit/test_media_manager.py     # 19 passed
uv run --frozen ruff check .                                # clean
uv run --frozen ruff format --check <changed files>         # clean
uv run --frozen mypy langfuse --no-error-summary            # clean

The upload URL was checked with `"storage.googleapis.com" in upload_url`,
so any URL containing that string (e.g. in a query parameter or as a
subdomain prefix of another domain) was treated as a GCS bucket and sent
without the x-ms-blob-type / x-amz-checksum-sha256 headers. Parse the URL
and compare the hostname instead.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@CLAassistant

CLAassistant commented Sep 30, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@Ad1th

Ad1th commented Oct 2, 2026

Copy link
Copy Markdown
Author

Following up on #1913: the contributing guide doesn't ask for assignment before a PR, so I went ahead and opened this one. Happy to rework it however you prefer (a helper instead of the inline hostname check, a different test layout, etc.).

I also added the exact verification commands to the description. Since this is from a fork, the CI workflows probably need a maintainer to approve the first run.

This branch has not been deployed

No deployments
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.

bug: GCS upload detection in MediaManager uses substring match on the full URL

2 participants