Skip to content

Conversation

@NicoHinderling
Copy link
Contributor

@NicoHinderling NicoHinderling commented Jan 23, 2026

With this webhook, the status check for size can call this webhook to mark an artifact as approved

Copy link
Contributor Author

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jan 23, 2026
@NicoHinderling NicoHinderling marked this pull request as ready for review January 23, 2026 00:16
@NicoHinderling NicoHinderling requested a review from a team as a code owner January 23, 2026 00:16
cursor[bot]

This comment was marked as outdated.

@NicoHinderling NicoHinderling force-pushed the 01-22-chore_preprod_add_github_webhook_handler_for_size_approve_action branch from 1390e38 to 1b9592a Compare January 23, 2026 17:53
cursor[bot]

This comment was marked as outdated.

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.

Log.APPROVAL_ALREADY_EXISTS,
extra={**extra, "sibling_artifact_id": sibling.id},
)
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

Duplicate approval check only examines latest approval

Medium Severity

The duplicate approval check queries only the latest_approval (ordered by -id) and compares its GitHub ID with the sender's ID. This prevents duplicates only when the same user's approval is the most recent one. If User A approves, then User B approves, then User A tries to approve again, the check fails because latest_approval is from User B, allowing User A to create a duplicate approval. The test docstring states "Same GitHub user clicking approve twice should not create duplicate," but this logic doesn't fully enforce that invariant.

Fix in Cursor Fix in Web

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that's intentional (cc @trevor-e thoughts)

@NicoHinderling NicoHinderling force-pushed the 01-22-chore_preprod_add_github_webhook_handler_for_size_approve_action branch from d41d978 to 4e90e3c Compare January 23, 2026 18:29
@NicoHinderling NicoHinderling force-pushed the 01-22-chore_preprod_add_github_webhook_handler_for_size_approve_action branch from 4e90e3c to 3a9ab9f Compare January 23, 2026 18:37
extra = {
"organization_id": organization.id,
"external_id": external_id,
"sender_login": sender.get("login"),
Copy link
Member

Choose a reason for hiding this comment

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

I think this will record the user's name, can we use their ID instead to avoid PII?

metrics.incr(Log.ARTIFACT_NOT_FOUND)
return

if artifact.project.organization_id != organization.id:
Copy link
Member

Choose a reason for hiding this comment

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

nit: can we include the organization.id as part of the PreprodArtifact query to keep that check atomic? if we don't find one for (artifact_id, org.id) then it should raise PreprodArtifact.DoesNotExist.

.first()
)

if latest_approval:
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this check is needed, there isn't much harm in just creating a new record every time. If you want to keep this we should fix the loop query though, it's possible to get this in a single query with a rank function.

repo=self.repo,
)

assert PreprodComparisonApproval.objects.count() == 0
Copy link
Member

Choose a reason for hiding this comment

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

Asserts like this might cause leakage between tests and assumes other tests creating PreprodComparisonApproval objects will clean up afterwards. Can we scope the query to the test org?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants