Skip to content

Conversation

@runningcode
Copy link
Contributor

Summary

Add new organization-level API endpoints that don't require project ID in the path for preprod artifact operations.

Changes

New Endpoints


    • Returns build details for an artifact without requiring project ID
    • Looks up project from artifact ID internally
    • Validates artifact belongs to organization

    • Returns size analysis for an artifact without requiring project ID
    • Same pattern as build-details endpoint

Implementation Details

Both endpoints:

  • Inherit from OrganizationEndpoint for organization-level access control
  • Use select_related("project") to efficiently fetch the associated project
  • Filter by project__organization_id=organization.id to prevent IDOR vulnerabilities
  • Return 404 if artifact not found or belongs to different organization
  • Require organizations:preprod-frontend-routes feature flag

Tests

Added comprehensive test coverage:

  • 7 tests for build-details endpoint
  • 9 tests for size-analysis endpoint

Test coverage includes:

  • Success cases with correct data
  • Not found scenarios (invalid ID, wrong organization)
  • Feature flag disabled
  • Invalid artifact ID format (non-numeric)
  • Failed artifact states
  • All size analysis states (pending, processing, failed, completed)

All tests pass ✅

Why

This enables simplified URL structures in the frontend where the project parameter can be optional. The artifact ID is globally unique within an organization, so we can look up the associated project internally.

The frontend makes two separate API calls that both need org-level variants:

  1. build-details: Lightweight metadata (app info, version, VCS info, state)
  2. size-analysis: Heavy data payload (treemap data, file sizes, breakdowns)

Security

Both endpoints validate that the artifact belongs to a project in the organization before returning data, preventing IDOR vulnerabilities:

preprod_artifact = PreprodArtifact.objects.get(
    id=artifact_id_int,
    project__organization_id=organization.id,  # ← Prevents IDOR
)

Related

Part of EME-725 URL restructuring work.

…(EME-725)

Add new endpoints that don't require project ID in the path:
- /organizations/{org}/preprodartifacts/{id}/build-details/
- /organizations/{org}/preprodartifacts/{id}/size-analysis/

These endpoints look up the project from the artifact ID internally and
validate that the artifact belongs to a project in the organization.

This enables the frontend to make API calls without requiring the project
parameter in the URL, simplifying the URL structure.
…ME-725)

Add comprehensive test coverage for the new organization-level endpoints:

- test_organization_preprod_artifact_build_details.py:
  * Success case with project info
  * Not found (invalid ID, wrong org)
  * Feature flag disabled
  * Invalid artifact ID format
  * Failed artifact state

- test_organization_preprod_artifact_size_analysis.py:
  * All size analysis states (pending, processing, failed, completed)
  * Not found (invalid ID, wrong org)
  * Feature flag disabled
  * Invalid artifact ID format

All tests pass and follow existing test patterns.
@runningcode runningcode requested a review from a team as a code owner January 15, 2026 18:33
@linear
Copy link

linear bot commented Jan 15, 2026

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jan 15, 2026
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jan 15, 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.

| '/organizations/$organizationIdOrSlug/data-secrecy/'
| '/organizations/$organizationIdOrSlug/derive-code-mappings/'
| '/organizations/$organizationIdOrSlug/detector-types/'
| '/organizations/$organizationIdOrSlug/detector-workflow/'
Copy link
Contributor

Choose a reason for hiding this comment

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

Unrelated endpoint definitions accidentally removed from generated file

Medium Severity

The generated TypeScript file removes two detector-workflow endpoint definitions that still exist in the backend (src/sentry/workflow_engine/endpoints/urls.py lines 87-94). These deletions are unrelated to the preprod artifact endpoints being added and appear to be accidental—possibly from regenerating the file incorrectly or a merge conflict. Frontend code referencing these endpoints may lose type safety or fail TypeScript compilation.

Fix in Cursor Fix in Web

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