← Back to issue list

`snaphelpers` getting snap config can fail when `snapd` is unavailable`

View original Github issue

Metadata

Project
charmcraft
Number
#921
Type
issue
State
open
Author
mr-cal
Labels
Created
Updated
Closed

Current evaluation

snaphelpers calls in charmcraft's configure hook can raise unhelpful errors when snapd is unavailable. Maintainer acknowledged as low priority (2024-08); only the configure hook still uses snaphelpers directly. Code still lacks the try/except fix.

Suggested action: keep open

Reason: Maintainer @lengau triaged this as low priority (2024-08-16), noting only the configure hook still uses snaphelpers directly. The code in charmcraft/snap.py still only catches UnknownConfigKey, not SnapCtlError/AttributeError, so the issue remains valid. It is a small, well-scoped fix that should stay open for eventual completion.

Impact: 15 Quick Win: 13.5 Staleness: 65 Complexity: 10 Confidence: 78 Support Request: 5

Issue body

This is a [suggestion](https://github.com/snapcore/snapcraft/pull/3971#pullrequestreview-1165612553) from @cmatsuoka to port some error handling from snapcraft to charmcraft: When charmcraft uses the `snaphelpers` library calls to fetch the snap config (e.g. `snap get charmcraft`), it can raise an `AttributeError` or `snaphelpers.SnapCtlError` if `snapd` is unavailable. The error messages are very unhelpful. Snapcraft solved this by wrapping the `snaphelpers` calls in a try/except block and a better error message ([source](https://github.com/snapcore/snapcraft/blob/main/snapcraft/snap_config.py))

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.8-27b
Impact: 15
Quick Win: 13.5
Staleness: 65
Complexity: 10
Confidence: 78
Support Request: 5
keep open snaphelpers calls in charmcraft's configure hook can raise unhelpful errors when snapd is unavailable. Maintainer acknowledged as low priority (2024-08); only the configure hook still uses snaphelpers directly. Code still lacks the try/except fix.
qwen/qwen3.6-35b-a3b
Staleness: 90
Complexity: 20
Confidence: 85
Support Request: 10
close stale Suggestion to improve error handling for snaphelpers snap config calls when snapd is unavailable. Marked low priority by a maintainer as the affected code path is now largely obsolete due to architectural changes.
qwen3.6-35b-a3b-mtp-q6
Staleness: 85
Complexity: 15
Confidence: 90
Support Request: 10
close stale Suggestion to improve error handling for snaphelpers snap config calls when snapd is unavailable. Marked low priority by a maintainer as direct usage is now limited to the configure script, with other paths handled by craft-application.
qwen3.6-35b-a3b-mtp-q6
Staleness: 92
Complexity: 18
Confidence: 85
Support Request: 10
close stale Suggestion to improve error handling for snaphelpers when snapd is unavailable. Maintainer marked it low priority, noting direct usage is now limited to a configure script and abstracted via craft-application.
qwen3.6-35b-a3b-mtp-q6
Staleness: 85
Complexity: 20
Confidence: 75
Support Request: 10
close stale Improve error handling for snaphelpers snap config calls when snapd is unavailable. Currently low priority as snaphelpers is only used in one legacy script. Internal tracking ticket CRAFT-3252 created.

Update history

No update history recorded yet.

Related work

  • Related To: canonical/snapcraft#3971 (confidence 90%)

    Referenced in the issue body as the source of the error-handling pattern to port; that PR fixed the same class of crash in snapcraft's snap_config.py.

Related issues

No related issues found above the similarity threshold.