Skip to content

Conversation

@ellisonmarks
Copy link
Contributor

google.api_core.exceptions.InvalidArgument: 400 GCS source Path argument must end with '/'

`google.api_core.exceptions.InvalidArgument: 400 GCS source Path argument must end with '/'`
@ellisonmarks ellisonmarks requested a review from a team as a code owner November 18, 2025 09:40
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 18, 2025
@ellisonmarks ellisonmarks enabled auto-merge (squash) November 18, 2025 09:41
transfer_job_name=None,
source_bucket=source_bucket,
source_prefix=f"{organization_id}",
source_prefix=f"{organization_id}/",
Copy link

Choose a reason for hiding this comment

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

Bug: export_replay_blob_data creates GCS transfer jobs with source_prefix values missing a trailing slash, violating GCS API requirements.
Severity: CRITICAL | Confidence: 1.00

🔍 Detailed Analysis

The export_replay_blob_data function in src/sentry/replays/data_export.py constructs source_prefix values like "30/1", "60/1", "90/1" without a trailing slash. The Google Cloud Storage Transfer Service API requires source paths to end with a /. This will cause google.api_core.exceptions.InvalidArgument: 400 GCS source Path argument must end with '/' errors when attempting to create transfer jobs, making replay blob exports non-functional.

💡 Suggested Fix

Modify src/sentry/replays/data_export.py to append a trailing slash to source_prefix in export_replay_blob_data, e.g., source_prefix=f"{retention_days}/{project_id}/". Update test_export_replay_blob_data() to assert the correct path format.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/sentry/profiles/data_export.py#L47

Potential issue: The `export_replay_blob_data` function in
`src/sentry/replays/data_export.py` constructs `source_prefix` values like `"30/1"`,
`"60/1"`, `"90/1"` without a trailing slash. The Google Cloud Storage Transfer Service
API requires source paths to end with a `/`. This will cause
`google.api_core.exceptions.InvalidArgument: 400 GCS source Path argument must end with
'/'` errors when attempting to create transfer jobs, making replay blob exports
non-functional.

Did we get this right? 👍 / 👎 to inform future reviews.

Reference_id: 2760760

@codecov
Copy link

codecov bot commented Nov 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #103509      +/-   ##
===========================================
+ Coverage   78.03%    80.68%   +2.65%     
===========================================
  Files        9245      9247       +2     
  Lines      394973    394995      +22     
  Branches    25190     25190              
===========================================
+ Hits       308215    318701   +10486     
+ Misses      86327     75863   -10464     
  Partials      431       431              

@ellisonmarks ellisonmarks merged commit b878791 into master Nov 18, 2025
66 checks passed
@ellisonmarks ellisonmarks deleted the emarks/profiles-export-slash branch November 18, 2025 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants