← Back to issue list

Config service should check whether the program is running in the app's snap

View original Github issue

Metadata

Project
craft-application
Number
#816
Type
issue
State
open
Author
lengau
Labels
—
Created
Updated
Closed
—

Current evaluation

Config service's SnapConfigHandler uses snaphelpers.is_snap() (true for any snap) instead of verifying we run in the app's own snap. Repo already has util.is_running_from_snap(app_name) used by provider.py. Open, unfixed.

Suggested action: keep open

Reason: The bug is confirmed present at HEAD: craft_application/services/config.py:106 still calls `snaphelpers.is_snap()`, which returns true inside any snap (e.g. a snapped terminal), whereas the correct helper `util.is_running_from_snap(self._app.name)` (checking `SNAP_NAME == app_name and SNAP is not None`) already exists in craft_application/util/snap_config.py and is already used by provider.py:144. A reproducer is trivially given ('Set the SNAP environment variable') and the fix is a one-line swap plus updating the two tests that patch `snaphelpers.is_snap` in tests/unit/services/test_config.py. Impact is moderate rather than severe: worst case is a spurious 'Snap environment is set, but cannot connect to snapd' progress message and OSError in the snap handler, not data loss or breakage.

Evaluated by: mr-cal-bot

Impact: 32 Quick Win: 24 Complexity: 15 Confidence: 90 Actionability: 88

Issue body

### Bug Description https://github.com/canonical/craft-application/blob/86fcd4078907cf084367d38fceda1b8a52b97911/craft_application/services/config.py#L91-L97 Currently we just check if we're running in *a* snap, we should check if we're running in the app's snap. ### To Reproduce Set the `SNAP` environment variable ### part yaml ```shell ``` ### Relevant log output ```shell n/a ```

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha
Impact: 32
Quick Win: 24
Complexity: 15
Confidence: 90
Actionability: 88
keep open Config service's SnapConfigHandler uses snaphelpers.is_snap() (true for any snap) instead of verifying we run in the app's own snap. Repo already has util.is_running_from_snap(app_name) used by provider.py. Open, unfixed.
qwen/qwen3.6-35b-a3b
Impact: 30
Quick Win: 19
Complexity: 20
Confidence: 75
Actionability: 80
needs triage SnapConfigHandler uses snaphelpers.is_snap() instead of checking if running in the app's specific snap, risking false positives from other snaps.
qwen/qwen3.8-27b
Impact: 35
Quick Win: 28
Staleness: 78
Complexity: 20
Confidence: 82
Support Request: 0
needs triage SnapConfigHandler uses snaphelpers.is_snap() instead of checking the app's specific snap name; the is_running_from_snap() utility exists but is unused here. Unaddressed for 410 days with no labels or maintainer response.
qwen/qwen3.6-35b-a3b
Staleness: 95
Complexity: 20
Confidence: 85
Support Request: 10
needs triage Config service incorrectly checks for any snap instead of the app's specific snap. Open for 369 days with no labels or maintainer response, awaiting triage.
qwen3.6-35b-a3b-mtp-q6
Staleness: 85
Complexity: 20
Confidence: 80
Support Request: 0
needs triage Config service incorrectly checks if running in any snap instead of the app's specific snap. Open with no labels or maintainer comments.

Update history

No update history recorded yet.

Related work

  • Related To: canonical/craft-application#239 (confidence 80%)

    Commit 21393ee7 'feat(snap_config): add snap_config model and utilities' introduced the is_running_from_snap helper that already implements the exact check this issue asks for.

  • Related To: canonical/craft-application#499 (confidence 75%)

    Commit 52eb37c4 'fix(config): wrap snap config handler in snap check' added the current snaphelpers.is_snap() guard that this issue asks to tighten.

  • Related To: canonical/snapcraft#5079 (confidence 60%)

    Referenced in the existing SnapCtlError handler comment as the same class of false-positive snap environment; tests/unit/services/test_provider.py:241 covers the 'kitty' terminal-snap case for the provider service.

Related issues

No related issues found above the similarity threshold.