← Back to issue list

snapcraft exit code 0 on unsuccesful uploads

View original Github issue

Metadata

Project
snapcraft
Number
#6119
Type
issue
State
closed
Author
mbeijen
Labels
—
Created
Updated
Closed

Current evaluation

Fixed by merged canonical/craft-application#1068 (58e0440f), which preserves non-success dispatcher return codes; Snapcraft 9.0 was verified to exit 1 for an HTTP 500 upload.

Resolution: closed resolved

Reason: canonical/craft-application#1068 merged as commit 58e0440f and limits the success fallback to cases where dispatcher.run() returns None, preventing error statuses from becoming 0. A maintainer also verified in Snapcraft 9.0 that an injected store HTTP 500 exits with status 1.

Evaluated by: mr-cal-bot

No scores available.

Issue body

### Check existing issues - [x] I've verified that this bug isn't described by any existing issues. ### Bug description Today snapcraft is having issues. I found that if I upload my package, it errors with a HTTP 500 but nevertheless the process exits with exit code `0`. This makes it difficult to use snapcraft in shell scripts for build pipelines and such. ``` $ snapcraft upload myproject_amd64.snap Uploading... 17744080/17744080 Issue encountered while processing your request: [500] Internal Server Error. Full execution log: '/home/michiel/.local/state/snapcraft/log/snapcraft-20260325-124413.959196.log' $ echo $? 0 ``` Expected behavior was to see a non-zero exit code ### Steps to reproduce Upload a snap to the snap store while snapcraft is having an outage ### Environment just uploading using snapcraft 8.14.4 installed as a snap ### snapcraft.yaml ```yaml ``` ### Log output ```shell 2026-03-25 12:44:13.960 Starting snapcraft, version 8.14.4 ... 2026-03-25 12:44:14.060 HTTP 'POST' for 'https://dashboard.snapcraft.io/dev/api/snap-push/' with params None and headers {'Accept': 'application/json', 'Authorization': '<macaroon>', 'User-Agent': 'snapcraft/8.14.4 ubuntu/25.10 (x86_64)'} 2026-03-25 12:44:14.188 Beginning to upload a file 'myproject.snap' with size of 17743872 bytes 2026-03-25 12:44:14.188 Uploading... (--->) 2026-03-25 12:44:14.189 Uploading... (<---) 2026-03-25 12:44:14.189 HTTP 'POST' for 'https://storage.snapcraftcontent.com/unscanned-upload/' with params None and headers {'Content-Type': 'multipart/form-data; boundary=1d9371e3d1244d58b4da1b1cea107374', 'Accept': 'application/json', 'User-Agent': 'snapcraft/8.14.4 ubuntu/25.10 (x86_64)'} 2026-03-25 12:45:20.033 Issue encountered while processing your request: [500] Internal Server Error. 2026-03-25 12:45:20.035 Traceback (most recent call last): 2026-03-25 12:45:20.035 File "/snap/snapcraft/17288/lib/python3.12/site-packages/snapcraft/application.py", line 183, in _run_inner 2026-03-25 12:45:20.035 return_code = super()._run_inner() 2026-03-25 12:45:20.035 ^^^^^^^^^^^^^^^^^^^^ 2026-03-25 12:45:20.035 File "/snap/snapcraft/17288/lib/python3.12/site-packages/craft_application/application.py", line 653, in _run_inner 2026-03-25 12:45:20.035 return_code = dispatcher.run() or os.EX_OK 2026-03-25 12:45:20.035 ^^^^^^^^^^^^^^^^ 2026-03-25 12:45:20.035 File "/snap/snapcraft/17288/lib/python3.12/site-packages/craft_cli/dispatcher.py", line 564, in run 2026-03-25 12:45:20.035 return self._loaded_command.run(self._parsed_command_args) 2026-03-25 12:45:20.035 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2026-03-25 12:45:20.035 File "/snap/snapcraft/17288/lib/python3.12/site-packages/snapcraft/commands/upload.py", line 131, in run 2026-03-25 12:45:20.035 snap_upload_id = client.store_client.upload_file( 2026-03-25 12:45:20.035 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2026-03-25 12:45:20.035 File "/snap/snapcraft/17288/lib/python3.12/site-packages/craft_store/base_client.py", line 261, in upload_file 2026-03-25 12:45:20.035 response = self.http_client.request( 2026-03-25 12:45:20.035 ^^^^^^^^^^^^^^^^^^^^^^^^^ 2026-03-25 12:45:20.035 File "/snap/snapcraft/17288/lib/python3.12/site-packages/craft_store/http_client.py", line 165, in request 2026-03-25 12:45:20.035 raise errors.StoreServerError(response) 2026-03-25 12:45:20.035 craft_store.errors.StoreServerError: Issue encountered while processing your request: [500] Internal Server Error. ```

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Fixed by merged canonical/craft-application#1068 (58e0440f), which preserves non-success dispatcher return codes; Snapcraft 9.0 was verified to exit 1 for an HTTP 500 upload.
stealth/space-bunny-alpha — closed resolved Snapcraft 9.0 now exits 1 for HTTP 500 upload failures; the 8.14.4 behavior was addressed upstream through canonical/craft-application#1068.
stealth/space-bunny-alpha — closed resolved Fixed in Snapcraft 9.0: forced HTTP 500 upload failures exit 1. The 8.14.4 root cause was traced to craft-application, with an upstream fix proposed in #1068.
stealth/space-bunny-alpha — closed resolved Upload HTTP 500 failures now exit 1 in Snapcraft 9.0; the 8.14.4 behavior was traced to craft-application, with an upstream fix attempted in canonical/craft-application#1068.
stealth/space-bunny-alpha — closed resolved Fixed in Snapcraft 9.0: store upload failures now return exit code 1; commit 9e02eb000 handles CraftStoreError, alongside upstream craft-application#1068.
stealth/space-bunny-alpha — closed resolved Snapcraft 9.0 fixed the behavior: a simulated HTTP 500 during upload exits with code 1, unlike 8.14.4, which exited 0.
stealth/space-bunny-alpha — closed resolved Fixed in Snapcraft 9.0: upload failures now exit 1. The older 8.14.4 behavior was traced to craft-application; upstream fix attempted in canonical/craft-application#1068.
qwen/qwen3.6-35b-a3b — — Fixed in Snapcraft 9.0. Upload failures now return non-zero exit codes. Craft-application previously normalized dispatcher results to success. Snapcraft now catches store errors and propagates exit code 1.
qwen/qwen3.6-35b-a3b — — Resolved via craft-application PR #1068. The bug stemmed from craft-application normalizing None returns to exit code 0. Verified in Snapcraft 9.0, which now correctly propagates exit code 1 on HTTP 500 upload failures.
qwen/qwen3.6-35b-a3b — — Fixed upstream in craft-application PR #1068. craft-application normalized None returns to success via or os.EX_OK. Snapcraft 9.0 now correctly propagates non-zero exit codes on upload failures, resolving the CI pipeline issue.
qwen3.6-35b-a3b-mtp-q6 — — Resolved via upstream craft-application PR #1068. The bug originated from craft-application normalizing None return values to a success exit code. Verified in Snapcraft 9.0 that upload failures now correctly return exit code 1. Closed.

Update history

No update history recorded yet.

Related work

Related issues

Issue Project State Summary Similarity
#1791968 Snapcraft lies when submission to sentry fails snapcraft (launchpad) closed Snapcraft now handles Sentry submission failures gracefully instead of falsely reporting success. Fix merged in canonical/snapcraft#2271 via commit 859c111e5.
70%