Skip to content

fix: allow running export-login twice to the same file - #6302

Open
mbeijen wants to merge 3 commits into
canonical:mainfrom
mbeijen:6301-fix-export-login-two-times
Open

fix: allow running export-login twice to the same file#6302
mbeijen wants to merge 3 commits into
canonical:mainfrom
mbeijen:6301-fix-export-login-two-times

Conversation

@mbeijen

@mbeijen mbeijen commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Closes #6301

Makes sure there is no 'internal error' when generating credentials twice to the same file.


  • I've followed the contribution guidelines.
  • I've signed the CLA.
  • I've successfully run make lint && make test.
  • I've updated the relevant release notes.

@mbeijen
mbeijen requested review from a team and mr-cal as code owners June 23, 2026 10:28
Copilot AI review requested due to automatic review settings June 23, 2026 10:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a regression/bug in snapcraft export-login where re-exporting credentials to the same (now owner-read-only) file could fail with a PermissionError, and adds coverage + release note entry for the behavior.

Changes:

  • Adjust export-login to restore owner write permission on an existing credentials file before rewriting it.
  • Add a unit test that runs export-login twice against the same file and asserts the final permissions remain owner-read-only.
  • Document the fix in the Snapcraft 9.0.0 release notes.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
snapcraft/commands/account.py Adds a pre-write chmod to allow rewriting an existing owner-read-only credentials file.
tests/unit/commands/test_account.py Adds regression test for running export-login twice to the same file and preserving 0400 permissions.
docs/release-notes/snapcraft-9-0.rst Adds a 9.0.0 fixed-issues bullet referencing #6301.

Comment thread snapcraft/commands/account.py
@mbeijen
mbeijen force-pushed the 6301-fix-export-login-two-times branch from 701f770 to 04f8bb8 Compare June 23, 2026 10:35
@mbeijen mbeijen changed the title Fix running export-login twice fix: allow running export-login twice to the same file Jun 23, 2026
@mbeijen
mbeijen force-pushed the 6301-fix-export-login-two-times branch from 04f8bb8 to 7dfe29c Compare June 23, 2026 10:38
Comment thread docs/release-notes/snapcraft-9-0.rst Outdated

@medubelko medubelko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs LGTM, assuming a merge to main. Awaiting engineering review.

@mr-cal I assume this will actually end up fitting into 9.1.0?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants