Skip to content

Commit b64ea7e

Browse files
authored
bug(preprod): Fix incorrect URL being returned from assemble endpoint (#97811)
Resolves EME-214
1 parent de69e7d commit b64ea7e

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

src/sentry/preprod/api/endpoints/organization_preprod_artifact_assemble.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from sentry.api.bases.project import ProjectEndpoint, ProjectReleasePermission
1313
from sentry.debug_files.upload import find_missing_chunks
1414
from sentry.models.orgauthtoken import is_org_auth_token_auth, update_org_auth_token_last_used
15+
from sentry.models.project import Project
1516
from sentry.preprod.analytics import PreprodArtifactApiAssembleEvent
1617
from sentry.preprod.tasks import assemble_preprod_artifact, create_preprod_artifact
1718
from sentry.preprod.url_utils import get_preprod_artifact_url
@@ -96,7 +97,7 @@ class ProjectPreprodArtifactAssembleEndpoint(ProjectEndpoint):
9697
}
9798
}
9899

99-
def post(self, request: Request, project) -> Response:
100+
def post(self, request: Request, project: Project) -> Response:
100101
"""
101102
Assembles a preprod artifact (mobile build, etc.) and stores it in the database.
102103
"""
@@ -175,7 +176,7 @@ def post(self, request: Request, project) -> Response:
175176
if is_org_auth_token_auth(request.auth):
176177
update_org_auth_token_last_used(request.auth, [project.id])
177178

178-
artifact_url = get_preprod_artifact_url(project.organization_id, artifact_id)
179+
artifact_url = get_preprod_artifact_url(project.organization_id, project.slug, artifact_id)
179180

180181
return Response(
181182
{

src/sentry/preprod/url_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
from sentry.models.organization import Organization
44

55

6-
def get_preprod_artifact_url(organization_id: int, artifact_id: str) -> str:
6+
def get_preprod_artifact_url(organization_id: int, project_slug: str, artifact_id: str) -> str:
77
"""
88
Build a region/customer-domain aware absolute URL for the preprod artifact UI.
99
"""
1010
organization: Organization = Organization.objects.get_from_cache(id=organization_id)
1111

12-
path = f"/organizations/{organization.slug}/preprod/internal/{artifact_id}"
12+
path = f"/organizations/{organization.slug}/preprod/{project_slug}/{artifact_id}"
1313
return organization.absolute_url(path)

tests/sentry/preprod/api/endpoints/test_organization_preprod_artifact_assemble.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,9 @@ def test_assemble_basic(
362362
assert response.status_code == 200, response.content
363363
assert response.data["state"] == ChunkFileState.CREATED
364364
assert set(response.data["missingChunks"]) == set()
365-
expected_url = f"/organizations/{self.organization.slug}/preprod/internal/{artifact_id}"
365+
expected_url = (
366+
f"/organizations/{self.organization.slug}/preprod/{self.project.slug}/{artifact_id}"
367+
)
366368
assert expected_url in response.data["artifactUrl"]
367369

368370
mock_create_preprod_artifact.assert_called_once_with(
@@ -429,7 +431,9 @@ def test_assemble_with_metadata(
429431
assert response.status_code == 200, response.content
430432
assert response.data["state"] == ChunkFileState.CREATED
431433
assert set(response.data["missingChunks"]) == set()
432-
expected_url = f"/organizations/{self.organization.slug}/preprod/internal/{artifact_id}"
434+
expected_url = (
435+
f"/organizations/{self.organization.slug}/preprod/{self.project.slug}/{artifact_id}"
436+
)
433437
assert expected_url in response.data["artifactUrl"]
434438

435439
mock_create_preprod_artifact.assert_called_once_with(

0 commit comments

Comments
 (0)