Skip to content

feat(preprod): Add distribution error endpoint for launchpad#109497

Merged
runningcode merged 7 commits intomasterfrom
runningcode/distr-error-update
Mar 5, 2026
Merged

feat(preprod): Add distribution error endpoint for launchpad#109497
runningcode merged 7 commits intomasterfrom
runningcode/distr-error-update

Conversation

@runningcode
Copy link
Contributor

Add a dedicated endpoint (PUT .../files/preprodartifacts/{id}/distribution/) for launchpad to report distribution processing errors back to the monolith. This mirrors the existing ProjectPreprodSizeEndpoint pattern.

When launchpad encounters a distribution failure (unsupported artifact type, invalid code signature, simulator build), it needs a way to set installable_app_error_code and installable_app_error_message on the artifact so the frontend can display the reason. Previously, the only option was the general update endpoint which marks the entire artifact as failed — but distribution errors shouldn't affect the artifact's overall state.

Follow-up to #109062. The launchpad side that calls this endpoint is in getsentry/launchpad#567.

Refs EME-842, EME-422

@linear
Copy link

linear bot commented Feb 26, 2026

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Feb 26, 2026
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Feb 26, 2026
@github-actions
Copy link
Contributor

🚨 Warning: This pull request contains Frontend and Backend changes!

It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently.

Have questions? Please ask in the #discuss-dev-infra channel.

@runningcode runningcode marked this pull request as ready for review February 27, 2026 17:27
@runningcode runningcode requested a review from a team as a code owner February 27, 2026 17:27
runningcode and others added 2 commits March 5, 2026 15:23
Add a dedicated endpoint for launchpad to report distribution processing
errors back to the monolith, mirroring the existing size analysis
endpoint pattern. This sets installable_app_error_code and
installable_app_error_message on the PreprodArtifact.

Refs EME-842, EME-422
Co-Authored-By: Claude <noreply@anthropic.com>
Use parse_request_with_pydantic (which uses parse_obj_as) instead of
manual unpacking to properly handle non-dict JSON bodies. Add Field
constraint to error_code (0-3) matching the InstallableAppErrorCode
enum range. Also make the shared helper's error message generic.

Co-Authored-By: Claude <noreply@anthropic.com>
@runningcode runningcode force-pushed the runningcode/distr-error-update branch from 6c0487d to d386294 Compare March 5, 2026 14:25
Use getattr for model.__name__ since Annotated type aliases (like
PutSize) lack __name__, causing AttributeError on validation failure.

Co-Authored-By: Claude <noreply@anthropic.com>
ProjectPreprodArtifactAssembleGenericEndpoint.as_view(),
name="sentry-api-0-project-preprod-artifact-assemble-generic",
),
re_path(
Copy link
Contributor

Choose a reason for hiding this comment

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

is is possible to make this one just an org endpoint? I'm about to delete all the dual registered ones: #109878

Copy link
Contributor

@chromy chromy left a comment

Choose a reason for hiding this comment

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

lgtm % route

runningcode and others added 2 commits March 5, 2026 15:57
Move the distribution error endpoint from preprod_internal_urlpatterns
to preprod_organization_urlpatterns, dropping the project slug from the
URL path to match the other migrated org-scoped endpoints (EME-735).

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

Backend Test Failures

Failures on 7e8a293 in this run:

tests/sentry/preprod/api/endpoints/test_project_preprod_distribution.py::ProjectPreprodDistributionEndpointTest::test_bad_authlog
tests/sentry/preprod/api/endpoints/test_project_preprod_distribution.py:34: in test_bad_auth
    assert response.status_code == 401
E   assert 404 == 401
E    +  where 404 = <HttpResponse status_code=404, "text/html; charset=utf-8">.status_code
tests/sentry/preprod/api/endpoints/test_project_preprod_distribution.py::ProjectPreprodDistributionEndpointTest::test_bad_jsonlog
tests/sentry/preprod/api/endpoints/test_project_preprod_distribution.py:44: in test_bad_json
    assert response.status_code == 400
E   assert 404 == 400
E    +  where 404 = <HttpResponse status_code=404, "text/html; charset=utf-8">.status_code
tests/sentry/preprod/api/endpoints/test_project_preprod_distribution.py::ProjectPreprodDistributionEndpointTest::test_invalid_error_codelog
tests/sentry/preprod/api/endpoints/test_project_preprod_distribution.py:63: in test_invalid_error_code
    assert response.status_code == 400
E   assert 404 == 400
E    +  where 404 = <HttpResponse status_code=404, "text/html; charset=utf-8">.status_code
tests/sentry/preprod/api/endpoints/test_project_preprod_distribution.py::ProjectPreprodDistributionEndpointTest::test_missing_fieldslog
tests/sentry/preprod/api/endpoints/test_project_preprod_distribution.py:39: in test_missing_fields
    assert response.status_code == 400
E   assert 404 == 400
E    +  where 404 = <HttpResponse status_code=404, "text/html; charset=utf-8">.status_code
tests/sentry/preprod/api/endpoints/test_project_preprod_distribution.py::ProjectPreprodDistributionEndpointTest::test_non_dict_json_bodylog
tests/sentry/preprod/api/endpoints/test_project_preprod_distribution.py:68: in test_non_dict_json_body
    assert response.status_code == 400
E   assert 404 == 400
E    +  where 404 = <HttpResponse status_code=404, "text/html; charset=utf-8">.status_code
tests/sentry/preprod/api/endpoints/test_project_preprod_distribution.py::ProjectPreprodDistributionEndpointTest::test_requires_launchpad_rpc_authenticationlog
tests/sentry/preprod/api/endpoints/test_project_preprod_distribution.py:81: in test_requires_launchpad_rpc_authentication
    assert response.status_code == 401
E   assert 404 == 401
E    +  where 404 = <HttpResponse status_code=404, "text/html; charset=utf-8">.status_code
tests/sentry/preprod/api/endpoints/test_project_preprod_distribution.py::ProjectPreprodDistributionEndpointTest::test_set_errorlog
tests/sentry/preprod/api/endpoints/test_project_preprod_distribution.py:52: in test_set_error
    assert response.status_code == 200
E   assert 404 == 200
E    +  where 404 = <HttpResponse status_code=404, "text/html; charset=utf-8">.status_code

Add back project parameter to put() since the base class always passes
it. Update test URLs to use the new org-scoped route.

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Contributor

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

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



class PutDistribution(BaseModel):
error_code: int = Field(ge=0, le=3)
Copy link
Contributor

Choose a reason for hiding this comment

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

Hardcoded magic number coupled to enum max value

Low Severity

The error_code field uses Field(ge=0, le=3) where 3 is a magic number implicitly coupled to the current max value of InstallableAppErrorCode (PROCESSING_ERROR=3). If a new enum member is added to InstallableAppErrorCode, this Pydantic validation will silently reject the new value with no obvious link back to the enum, making it easy to miss during future updates. Referencing the enum directly (e.g., using its max value or validating membership) would keep the validation in sync automatically.

Fix in Cursor Fix in Web

@runningcode runningcode enabled auto-merge (squash) March 5, 2026 15:29
@runningcode runningcode merged commit 761c9a5 into master Mar 5, 2026
56 checks passed
@runningcode runningcode deleted the runningcode/distr-error-update branch March 5, 2026 15:33
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 Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants