Skip to content

fix(jobs): report artifact failures only when the build itself did not fail - #13882

Merged
ChiragAgg5k merged 7 commits into
mainfrom
fix/jobs-user-artifact-errors
Sep 24, 2026
Merged

ChiragAgg5k merged 7 commits into
mainfrom
fix/jobs-user-artifact-errors

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

#13856 made the Jobs worker throw PermanentFailure (so it reaches Sentry) for any failed build artifact whose code isn't a known user error. On Cloud that became one noisy issue (CLOUD-3R4B, about 400 events in 36 hours). Most of those were the user's own build failing:

Events (36h) Failure Whose
218 archive → artifact_timeout "output did not appear within 10s of worker exit" User. The build command failed, so there's no output to pack
168 archive → artifact_permission_denied Ours. Fixed in open-runtimes/orchestrator#111
15 source / cachePull → download_failed (DNS lookup and i/o timeout) Ours: network
4 source → download_http_error "download failed with status 403" User, when the source is a repository

1. Don't report artifacts that fail after the deployment has already failed

Post-job artifacts run whatever the exit code is. When a build fails, its exit callback marks the deployment failed, and then archive/output fail because there's no output. The worker now skips the report when the deployment was already failed before the callback:

 exit (non-zero) ─► deployment failed ─► archive fails (no output) ─► statusBefore = failed ─► not reported
 exit 0          ─► still building    ─► archive fails             ─► reported (our bug)
 source fails    ─► still waiting     ─►                              reported (unless the user's)

This also stops a second report when output fails straight after archive. The one case it misses: an artifact callback that reaches the worker before its failed build's exit is still reported. That's unlikely, because archive waits 10 seconds after the build ends before it fails.

2. Tell the user when their repository can't be downloaded

A repository source (type: vcs, which covers VCS and template deployments) that downloads with 401/403/404 now shows a reason instead of "Internal server error. Please try again.", and isn't reported:

Status Message
404 The repository, branch or commit could not be found. Check that it still exists.
401 / 403 Access to the repository was denied. Check that it is still accessible to your Git installation.

An uploaded source (manual/cli) is downloaded from Appwrite's own presigned URL, so the same status there is ours. It keeps the internal error and is still reported. For now the status is read from the message (download failed with status 403).

Test Plan

  • Ran real exit and artifact callback payloads through Jobs::action() locally, on an in-memory database. After a failed exit, "output missing" is not reported and the deployment still fails with "Build failed with exit code N.". After a clean exit it is reported. A repository 404 or 403 shows the reasons above and isn't reported. An uploaded source's 404 keeps the internal error and is reported. On main, every one of these is reported, and the repository cases show the internal error.
  • pint and phpstan are clean on the changed file.

Related PRs and Issues

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs? No API changes.

…t fail

A post-job artifact fails with no output to pack whenever the user's build
command fails, so every failed build became a Sentry event. Failures are
now held until the exit arrives and dropped when the build command exited
non-zero or ran out of memory. A repository source that downloads with
401/403/404 gets a reason the user can act on instead of an internal
error; an uploaded source keeps the internal error, since its URL is ours.
@greptile-apps

greptile-apps Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge based on the current review state; no new or outstanding findings remain.

Summary

The PR suppresses artifact-failure reports after a deployment has already failed and gives users specific messages for repository download failures. There are no changes since the previous review.

Reviews (3) · Last reviewed commit: "refactor(jobs): key repository download ..."

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/jobs-user-artifact-errors (after).

Metric Before After Change
🚀 Requests/sec 189.84 191.89 ⚪ +1.1%
⏱️ Latency P50 90.57 ms 90.48 ms ⚪ -0.1%
⏱️ Latency P95 212.48 ms 210.68 ms ⚪ -0.8%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 90.48 210.68 12,483 191.89 -1.8
Account 172.99 344.85 657 10.88 +12.45
TablesDB 86.8 166.47 6,789 107.91 +2.4
Storage 82.18 176.36 3,285 53.17 -2.05
Functions 132.45 258.25 1,752 28.84 -13.68

Top API waits (after)

API request Max wait (ms)
account.name.update 493.78
functions.variables.update 398.49
account.prefs.update 380
tablesdb.rows.get 374.62
functions.create 370.63

@ChiragAgg5k

Copy link
Copy Markdown
Member Author

@greptile review

@ChiragAgg5k
ChiragAgg5k merged commit 23e64b3 into main Sep 24, 2026
105 of 107 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the fix/jobs-user-artifact-errors branch September 24, 2026 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants