-
-
Notifications
You must be signed in to change notification settings - Fork 37
Closed
getsentry/sentry
#109785Description
Context
The existing code mappings API (POST /api/0/organizations/{org}/code-mappings/) requires internal IDs (repositoryId, integrationId, projectId) and only creates one mapping at a time. For CLI usage in multi-module Android projects, we need a single endpoint that accepts human-readable identifiers and bulk creates/updates mappings.
What
Create POST /api/0/organizations/{org}/code-mappings/bulk/ endpoint.
Request format:
{
"project": "my-android-app",
"repository": "getsentry/sentry-android",
"defaultBranch": "main",
"mappings": [
{"stackRoot": "com/example/maps", "sourceRoot": "modules/maps/src/main/java/com/example/maps"}
]
}Endpoint logic:
- Validate request body via serializer (max 200 mappings)
- Resolve project by slug —
Project.objects.get(organization=org, slug=..., status=ACTIVE) - Check project access —
request.access.has_project_access(project) - Resolve repository by name —
Repository.objects.get(organization_id=..., name=..., status=ACTIVE) - Derive
integration_idandorganization_integration_idfrom the repository - Validate
defaultBranch(required unless Perforce integration) - Loop through mappings —
RepositoryProjectPathConfig.objects.update_or_create()keyed on(project, stack_root) - Return per-mapping results (created/updated/error), HTTP 200 on full success, 207 on partial failure
Key decisions:
- Upsert by
(project, stack_root)— matches existing unique constraint - Best-effort processing (not atomic)
- Duplicate
stackRootin same request → last-write-wins - Multiple repos with same name → return 409
Reusable code:
gen_path_regex_field()fromorganization_code_mappings.py— path validationBRANCH_NAME_ERROR_MESSAGE— branch regexintegration_service.get_organization_integration()— org-integration resolution
Files
- Create:
src/sentry/integrations/api/endpoints/organization_code_mappings_bulk.py - Modify:
src/sentry/api/urls.py(register route beforecode-mappings/{config_id}/catch-all)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Fields
Give feedbackNo fields configured for issues without a type.