Repository navigation
Warn when the installation ID can't be saved; add require_persisted - #7
Merged
Merged
Conversation
…ire_persisted get_or_create_installation_id swallowed write errors and returned an unsaved ID, so every launch on a read-only or sandboxed disk produced a new ID and used another activation slot, with no signal to the app. - Default behaviour is unchanged: an unsaved ID is still returned, but one InstallationIdWarning (a RuntimeWarning subclass) is now emitted per process. - New keyword-only require_persisted=False. With True it raises InstallationIdError (an OSError subclass, with path) when the ID can't be saved and read back, or an existing file can't be read. - The saved value is read back to confirm it persisted. - InstallationIdError and InstallationIdWarning are exported from keymint. - Tests, README and CHANGELOG.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
identity.get_or_create_installation_id()swallowed write errors and returned an unsaved ID. On a read-only disk, in a sandbox, or without permission to write~/.keymint, every launch generated a different ID, so the same machine used another activation slot each time, and the app got no signal.Change (backwards compatible)
InstallationIdWarning(aRuntimeWarningsubclass) per process naming the storage path.require_persisted=False. WithTrueit raisesInstallationIdErrorwhen the ID can't be saved and read back, or an existing file can't be read.InstallationIdErrorsubclassesOSError(so existingexcept OSErrorhandlers still catch it) and haspath.str).InstallationIdErrorandInstallationIdWarningare exported fromkeymint.require_persisted=Truefor desktop apps that activate devices.No version bump.
Tests
New
tests/test_identity.py:InstallationIdErrorwith the path;pytest -q tests: 97 passed.ruff check .: clean.