Can not update build status on deleted commit (results in stuck builds)

We're experiencing an issue with external builds being stuck in running status.

These builds were triggered by commits that now no longer exist (due to amend or rebasing) but before they were updated to success/failed by the external builder.

After poking at these builds through the api with curl, we hope the following reproduction steps are accurate in narrowing down the issue and fixing it.

Reproduction steps:

  1. Commit something
  2. Post running state (curl -X POST -H "PRIVATE-TOKEN: token" "https://gitlab.com/api/v3/projects/:id/statuses/:sha" -F "state=running" -F "name=test" -F "ref=master")
  3. Amend commit and force push
  4. Post succes state to original commit (curl -X POST -H "PRIVATE-TOKEN: token" "https://gitlab.com/api/v3/projects/:id/statuses/:sha" -F "state=success" -F "name=test" -F "ref=master")

Expected behaviour

Step 4 updates build status to success

Actual behaviour

Step 4 returns: {"message":"404 Commit Not Found"}

Additional information

Admins should be able to find builds stuck in this state on our private repository on pipeline id 3295024 and 3294632, with build ids 14401651 and 1440053

Edited Jun 23, 2025 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading