Skip to content

feat(code-mappings): Add batch splitting for large uploads#3210

Merged
romtsn merged 10 commits intomasterfrom
rz/feat/code-mappings-batching
Mar 24, 2026
Merged

feat(code-mappings): Add batch splitting for large uploads#3210
romtsn merged 10 commits intomasterfrom
rz/feat/code-mappings-batching

Conversation

@romtsn
Copy link
Copy Markdown
Member

@romtsn romtsn commented Mar 12, 2026

#skip-changelog

Split large mapping files into batches of 300 (the backend limit) per request.
Each batch is sent sequentially with progress reporting, and results are merged
into a single summary.

Also changes the output table to only show error rows — for large uploads
(hundreds of mappings), printing every row would flood the terminal. Successful
mappings are reflected in the summary counts instead.

Stack: #3207#3208#3209#3210

Backend PRs: getsentry/sentry#109783, getsentry/sentry#109785, getsentry/sentry#109786

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 12, 2026

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against f795997

@romtsn romtsn force-pushed the rz/feat/code-mappings-batching branch from 7cb21c6 to 5b0bce3 Compare March 12, 2026 10:55
@romtsn romtsn force-pushed the rz/feat/code-mappings-api-integration branch from f5ab182 to 37fbb57 Compare March 12, 2026 10:55
@romtsn romtsn force-pushed the rz/feat/code-mappings-batching branch from 5b0bce3 to a7afb81 Compare March 12, 2026 11:11
@romtsn romtsn force-pushed the rz/feat/code-mappings-api-integration branch 2 times, most recently from 5720ec2 to bbc4d47 Compare March 12, 2026 11:30
@romtsn romtsn force-pushed the rz/feat/code-mappings-batching branch 2 times, most recently from 3fcf380 to 8735962 Compare March 12, 2026 11:43
@romtsn romtsn marked this pull request as ready for review March 18, 2026 12:12
@romtsn romtsn requested review from a team and szokeasaurusrex as code owners March 18, 2026 12:12
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

@szokeasaurusrex
Copy link
Copy Markdown
Member

Please check and resolve the open comments from the AI reviewers, before I do a full review. If any comments are inaccurate or non-actionable, please indicate that with a 👎 and mark the comment as resolved. Thanks! 🙏

@romtsn romtsn force-pushed the rz/feat/code-mappings-api-integration branch from 3d14593 to e288070 Compare March 18, 2026 17:54
@romtsn romtsn force-pushed the rz/feat/code-mappings-batching branch from 0434afa to 4b94685 Compare March 18, 2026 20:14
Copy link
Copy Markdown
Member

@szokeasaurusrex szokeasaurusrex left a comment

Choose a reason for hiding this comment

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

Left some l comments, which I would strongly recommend addressing before merge

@szokeasaurusrex
Copy link
Copy Markdown
Member

Ah also @romtsn, please add a changelog entry, either in this PR or a follow-up 🙏

romtsn added a commit that referenced this pull request Mar 20, 2026
_#skip-changelog_

Add the `sentry-cli code-mappings upload` subcommand group and the
`upload`
subcommand with file parsing and validation.

This is the first in a stack of 4 PRs to support bulk uploading code
mappings
from a JSON file — useful for Java/Android multi-module projects that
need
dozens of mappings.

This PR adds:
- Command scaffold following the `repos`/`deploys` pattern
- JSON file reading and validation (empty arrays, empty
stackRoot/sourceRoot)
- CLI args: positional `PATH`, `--repo`, `--default-branch`
- Help and no-subcommand trycmd integration tests

Stack: **#3207** → #3208#3209#3210

Backend PRs: getsentry/sentry#109783, getsentry/sentry#109785,
getsentry/sentry#109786

Closes getsentry/sentry-android-gradle-plugin#1076
Closes getsentry/sentry-android-gradle-plugin#1077

---------

Co-authored-by: Claude Opus 4.6 <[email protected]>
romtsn added a commit that referenced this pull request Mar 24, 2026
…3208)

*#skip-changelog*

When `--repo` or `--default-branch` are not provided, infer them from
the<br>local git repository. Uses the configured VCS remote
(SENTRY_VCS_REMOTE / ini)<br>first, then falls back to best-effort
remote detection (upstream > origin > first).

Also extracts `find_best_remote()` as a shared utility in
`src/utils/vcs.rs`,<br>replacing the inline logic that was duplicated in
`git_repo_base_repo_name_preserve_case`.

Stack: #3207 →
[#3208](<#3208>) →
[#3209](<#3209>) →
[#3210](<#3210>)

Backend PRs:
[getsentry/sentry#109783](<getsentry/sentry#109783>),
[getsentry/sentry#109785](<getsentry/sentry#109785>),
[getsentry/sentry#109786](<getsentry/sentry#109786>)

Closes
[GRADLE-79](https://linear.app/getsentry/issue/GRADLE-79/add-git-inference-for-repo-name-and-default-branch)

---------

Co-authored-by: Claude Opus 4.6 <[email protected]>
@romtsn romtsn force-pushed the rz/feat/code-mappings-api-integration branch from a008901 to 42740cf Compare March 24, 2026 10:28
romtsn added a commit that referenced this pull request Mar 24, 2026
…#3209)

_#skip-changelog_

Connect the `code-mappings upload` command to the bulk code mappings API
endpoint (`POST /api/0/organizations/{org}/code-mappings/bulk/`).

Adds:
- `bulk_upload_code_mappings()` method on `AuthenticatedApi`
- Request/response data types in `src/api/data_types/code_mappings.rs`
- Summary table and error reporting in the command output
- Happy-path integration test with mock endpoint

Stack: #3207#3208 → **#3209** → #3210

Backend PRs: getsentry/sentry#109783, getsentry/sentry#109785,
getsentry/sentry#109786

Closes getsentry/sentry-android-gradle-plugin#1079

---------

Co-authored-by: Claude Opus 4.6 <[email protected]>
Base automatically changed from rz/feat/code-mappings-api-integration to master March 24, 2026 13:22
@romtsn romtsn force-pushed the rz/feat/code-mappings-batching branch from 1b835b3 to c29479d Compare March 24, 2026 13:37
@romtsn
Copy link
Copy Markdown
Member Author

romtsn commented Mar 24, 2026

addressed PR review in 38e43fa + added a changelog entry

romtsn and others added 2 commits March 24, 2026 19:49
Split large mapping files into batches of 300 (the backend limit)
per request. Each batch is sent sequentially with progress reporting.
Results are merged into a single summary table.

Batch-level HTTP failures are captured without aborting remaining
batches, and the final exit code reflects any errors.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
For large uploads (hundreds of mappings), printing every row floods
the terminal. Show only failed mappings in the table since those are
actionable; successful ones are already reflected in the summary counts.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
romtsn and others added 7 commits March 24, 2026 19:49
Verify the CLI correctly handles HTTP 207 Multi-Status responses from the
bulk code-mappings endpoint. The CLI treats 207 as a success at the HTTP
level and relies on the JSON body to surface per-mapping errors.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
The Errors count in the summary line now includes both per-mapping
errors and batch-level transport failures, matching the bail message.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
- Use div_ceil and lazy chunks iteration instead of collecting into Vec
- Implement FromIterator for MergedResponse to separate merging from
  request logic
- Avoid allocating Vec in print_error_table, iterate filter directly
- Use AtomicU8 instead of AtomicU16 in test

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@romtsn romtsn force-pushed the rz/feat/code-mappings-batching branch from 72c6ab9 to e30e462 Compare March 24, 2026 18:50
The 207 test was identical to the 200 partial error test — same response
body, same expected CLI output. No special 207 handling exists in the
API client, so the test added no coverage.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@romtsn romtsn merged commit 94a8931 into master Mar 24, 2026
26 checks passed
@romtsn romtsn deleted the rz/feat/code-mappings-batching branch March 24, 2026 21:54
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