← Back to issue list

Using export-login on a credentials file that already exist fails with 'internal error'

View original Github issue

Metadata

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

Current evaluation

export-login crashed with PermissionError when the target credentials file already existed. Fixed by merged PR #6302 (commit df5e9d668); the command now raises a clear SnapcraftError. Shipped in Snapcraft 9.1.1.

Resolution: closed resolved

Reason: PR canonical/snapcraft#6302 ("fix: error when export-login target file already exists", commit df5e9d668) was merged and closed the issue. In snapcraft/commands/account.py, ExportLoginCommand.run now checks os.path.lexists(parsed_args.login_file) before logging in and raises errors.SnapcraftError telling the user to rename or remove the existing file. Release notes for Snapcraft 9.1.1 list snapcraft#6301 as a fixed bug.

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 If I am using `snapcraft export-login` to export a macaroon and I re-run the command because for instance I forgot to change the acls or other parameters, I get `internal server error: PermissionError`. My expectation was that I just can re-run the command. ### Steps to reproduce First time works: ``` $ snapcraft export-login --snaps mysnap --channels mychannel --acls package_push,package_release --expires 2026-07-01T23:59:59Z mysnap.cred ... Email: michiel@example.com Password: Exported login credentials to 'mysnap.cred' ``` second time fails! ``` $ snapcraft export-login --snaps mysnap --channels mychannel --acls package_push,package_release --expires 2026-08-01T23:59:59Z mysnap.cred ... Email: michiel@example.com Password: snapcraft internal error: PermissionError(13, 'Permission denied') Full execution log: '/home/michiel/.local/state/snapcraft/log/snapcraft-xxxx.log' ``` ### Environment On Ubuntu 26.04 LTS, exporting credentials ### snapcraft.yaml ```yaml ``` ### Log output ```shell ```

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved export-login crashed with PermissionError when the target credentials file already existed. Fixed by merged PR #6302 (commit df5e9d668); the command now raises a clear SnapcraftError. Shipped in Snapcraft 9.1.1.
stealth/space-bunny-alpha — closed stale Reported an export-login PermissionError when reusing an existing credentials file; no resolving PR, commit, or maintainer explanation is identified.
qwen/qwen3.6-35b-a3b — — Closed. The snapcraft export-login command was updated to gracefully handle existing credential files, resolving the PermissionError encountered during re-execution.
qwen3.6-35b-a3b-mtp-q6
Impact: 35
Quick Win: 26
Staleness: 65
Complexity: 25
Confidence: 75
Support Request: 5
needs triage snapcraft export-login fails with PermissionError when the output file already exists, preventing re-runs with the same filename.
qwen/qwen3.6-35b-a3b
Staleness: 10
Complexity: 40
Confidence: 85
Support Request: 10
needs triage Bug report: 'snapcraft export-login' fails with PermissionError when overwriting an existing credentials file. No maintainer response yet.
qwen3.6-35b-a3b-mtp-q6
Staleness: 40
Complexity: 15
Confidence: 90
Support Request: 10
needs triage snapcraft export-login fails with PermissionError when the output credentials file already exists. Issue is unlabelled, has no maintainer comments, and is awaiting initial triage.

Update history

Date Change
closed

Related work

  • Likely Fixed By: snapcraft#6302 (confidence 99%)

    Merged PR whose commit df5e9d668 added the pre-login existence check in snapcraft/commands/account.py, with unit test in tests/unit/commands/test_account.py.

Related issues

Issue Project State Summary Similarity
#6302 fix: error when export-login target file already exists snapcraft merged Merged PR #6302 (commit df5e9d668) fixing #6301: export-login now raises an explicit SnapcraftError when the target credentials file exists, instead of crashing with an internal error. Shipped in Snapcraft 9.1.1.
88%