← Back to issue list

StorePushError doesn't grok the new store error responses

View original Launchpad issue

Metadata

Project
snapcraft (launchpad)
Number
#1705684
Type
issue
State
closed
Author
~roadmr
Labels
—
Created
Updated
Closed

Current evaluation

Fixed by merged PR #2749 (commit ac2d48293), which added StoreErrorList and updated StorePushError handling for structured store responses.

Resolution: closed resolved

Reason: The linked PR canonical/snapcraft#2749 was merged as commit ac2d48293. It added StoreErrorList and improved StorePushError handling for structured resource-not-found and resource-forbidden responses, preventing failures caused by a missing text field.

Evaluated by: mr-cal-bot

No scores available.

Issue body

When trying to push a snap to the wrong store an error response was generated, but snapcraft crashed without showing an appropriate error message built from the response. This seems to be because the StorePushError exception is trying to get the 'text' from the response's json but there isn't one. How to reproduce: Apply this change to snapcraft to send a store header: diff --git a/snapcraft/storeapi/__init__.py b/snapcraft/storeapi/__init__.py index 8d8e208..853e0ad 100644 --- a/snapcraft/storeapi/__init__.py +++ b/snapcraft/storeapi/__init__.py @@ -582,6 +582,7 @@ class SCAClient(Client): 'snap-push/', data=json.dumps(data), headers={'Authorization': auth, 'Content-Type': 'application/json', + 'X-Ubuntu-Store': 'whatever', 'Accept': 'application/json'}) if not response.ok: raise errors.StorePushError(data['name'], response) - Try to push a snap This is what I get: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/snapcraft/cli/store.py", line 123, in push snapcraft.push(snap_file, channel_list) File "/usr/lib/python3/dist-packages/snapcraft/_store.py", line 424, in push store.push_precheck(snap_name) File "/usr/lib/python3/dist-packages/snapcraft/storeapi/__init__.py", line 204, in push_precheck self.sca.snap_push_precheck, snap_name) File "/usr/lib/python3/dist-packages/snapcraft/storeapi/__init__.py", line 183, in _refresh_if_necessary return func(*args, **kwargs) File "/usr/lib/python3/dist-packages/snapcraft/storeapi/__init__.py", line 572, in snap_push_precheck raise errors.StorePushError(data['name'], response) snapcraft.storeapi.errors.StorePushError: <exception str() failed> During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/bin/snapcraft", line 32, in <module> obj=dict(project=snapcraft.ProjectOptions())) File "/usr/lib/python3/dist-packages/click/core.py", line 716, in __call__ return self.main(*args, **kwargs) File "/usr/lib/python3/dist-packages/click/core.py", line 696, in main rv = self.invoke(ctx) File "/usr/lib/python3/dist-packages/click/core.py", line 1060, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/lib/python3/dist-packages/click/core.py", line 889, in invoke return ctx.invoke(self.callback, **ctx.params) File "/usr/lib/python3/dist-packages/click/core.py", line 534, in invoke return callback(*args, **kwargs) File "/usr/lib/python3/dist-packages/snapcraft/cli/store.py", line 125, in push echo.error(e) File "/usr/lib/python3/dist-packages/snapcraft/cli/echo.py", line 42, in error click.echo('\033[0;31m{}\033[0m'.format(msg)) File "/usr/lib/python3/dist-packages/snapcraft/internal/errors.py", line 42, in __str__ return self.fmt.format([], **self.__dict__) KeyError: 'text' The response contains this (note: no text). b'{"error_list": [{"message": "Invalid store.", "code": "invalid-field", "extra": {"field": "X-Ubuntu-Store", "value": "planeo"}}]}'

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Fixed by merged PR #2749 (commit ac2d48293), which added StoreErrorList and updated StorePushError handling for structured store responses.
stealth/space-bunny-alpha — closed resolved Fixed structured StorePushError handling by adding StoreErrorList in snapcore/snapcraft#2749, merged as commit ac2d48293.
stealth/space-bunny-alpha — closed resolved Fixed by commit ac2d48293, which added StoreErrorList to format error_list store responses without a text field.
qwen/qwen3.6-35b-a3b — — Closed with no activity. The StorePushError parsing bug was abandoned, with no fix or merge linked.
qwen/qwen3.6-35b-a3b — — Closed without comments or resolution, likely abandoned or superseded by newer API versions. The StorePushError crash caused by missing JSON text keys remains unaddressed.
qwen/qwen3.6-35b-a3b — — Closed without resolution. Reported a crash in StorePushError when parsing new store API responses missing a 'text' field, causing a KeyError. No fix or PR was linked.
qwen3.6-35b-a3b-mtp-q6 — — Closed without comments or resolution. The issue appears abandoned or superseded by later code updates that revised store API error handling.

Update history

Date Change
created

Related work

  • Likely Fixed By: canonical/snapcraft#2749 (confidence 100%)

    Merged PR adding structured store-error handling and resolving the reported StorePushError failure.

Related issues

Issue Project State Summary Similarity
#2749 storeapi: add StoreErrorList to handle store errors snapcraft merged Merged in #2749 via commit ac2d48293, adding StoreErrorList and improving StorePushError handling for resource-not-found and resource-forbidden responses.
72%