Skip to content

feat(code-mappings): Wire up API integration for code-mappings upload#3209

Open
romtsn wants to merge 13 commits intorz/feat/code-mappings-git-inferencefrom
rz/feat/code-mappings-api-integration
Open

feat(code-mappings): Wire up API integration for code-mappings upload#3209
romtsn wants to merge 13 commits intorz/feat/code-mappings-git-inferencefrom
rz/feat/code-mappings-api-integration

Conversation

@romtsn
Copy link
Member

@romtsn romtsn commented Mar 12, 2026

#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

@github-actions
Copy link
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 a008901

Add a new `code-mappings` subcommand group with an `upload` subcommand
that reads and validates a JSON file of code mappings. This is the first
step toward CLI support for bulk code mapping uploads to Sentry.
@romtsn romtsn force-pushed the rz/feat/code-mappings-api-integration branch from 37fbb57 to 5720ec2 Compare March 12, 2026 11:11
@romtsn romtsn force-pushed the rz/feat/code-mappings-git-inference branch from 912da39 to 95e8814 Compare March 12, 2026 11:11
@romtsn romtsn force-pushed the rz/feat/code-mappings-api-integration branch from 5720ec2 to bbc4d47 Compare March 12, 2026 11:30
@romtsn romtsn marked this pull request as ready for review March 18, 2026 11:44
@romtsn romtsn requested review from a team and szokeasaurusrex as code owners March 18, 2026 11:44
Copy link
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.

lgtm, added some minor optional improvements

romtsn and others added 6 commits March 18, 2026 17:52
Add descriptive help text explaining what code mappings are and how they
work. Replace unwrap with expect for the required path argument.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Automatically detect repository name and default branch from the local
git repo when --repo or --default-branch are not provided. Respects
SENTRY_VCS_REMOTE config, falling back to best-effort remote detection.

Extract find_best_remote() into vcs.rs to deduplicate remote selection
logic shared with git_repo_base_repo_name_preserve_case().
When --repo is provided but --default-branch is not, the code no longer
requires a git remote to be present. Branch inference gracefully falls
back to 'main' when no git repo or remote is available.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@romtsn romtsn force-pushed the rz/feat/code-mappings-git-inference branch from e405066 to 8f9babe Compare March 18, 2026 17:15
romtsn and others added 3 commits March 18, 2026 18:41
Use get_repo_from_remote_preserve_case instead of get_repo_from_remote
to avoid lowercasing the repository name, which would cause mismatches
with Sentry's case-sensitive API.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add bulk_upload_code_mappings() API method and BulkCodeMappingsRequest/
Response data types. Wire up the upload command to authenticate, call
the bulk endpoint, and display results in a table with summary counts.
Exit with code 1 if any mappings fail.
@romtsn romtsn force-pushed the rz/feat/code-mappings-api-integration branch from 3d14593 to e288070 Compare March 18, 2026 17:54
Copy link

@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.

romtsn and others added 2 commits March 18, 2026 21:04
The bulk code-mappings endpoint is scoped to an organization, so a 404
should report "organization not found" rather than generic "resource
not found", consistent with other org-scoped endpoints.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Simplify the status match per review feedback and extract the table
building logic into a print_results_table function.

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

🚀

pub repository: String,
pub default_branch: String,
pub mappings: Vec<BulkCodeMapping>,
}
Copy link
Member

Choose a reason for hiding this comment

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

m: Because of how we use this in #3210, I think this struct should probably use borrowed, instead of owned, types. This would avoid cloning in #3210

pub struct BulkCodeMappingsRequest<'a> {
    pub project: &'a str,
    pub repository: &'a str,
    pub default_branch: &'a str,
    pub mappings: &'a [BulkCodeMapping],
}

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 <noreply@anthropic.com>
@romtsn romtsn force-pushed the rz/feat/code-mappings-git-inference branch from 70ddd86 to 6dae115 Compare March 20, 2026 21:35
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