Fix/secret store cross platform#3
Merged
Merged
Conversation
added 2 commits
July 7, 2026 12:13
Three minimalist bug fixes for the secret store introduced in PR #2: 1. _ensure_backend: catch ImportError when secret_store_backends is unimportable (Windows has no fcntl module). The consolidated macOS backend is irrelevant off macOS anyway. 2. _write_fallback: use hasattr(os, 'fchmod') guard and fall back to os.chmod on the path. os.fchmod is POSIX-only and raises AttributeError on Windows, which the existing except OSError would not catch. 3. set_secret: when the keyring backend is healthy but the write fails (transient error, dismissed Keychain prompt, etc.), warn instead of silently writing to the fallback file. The old behavior stranded the secret because get_secret skips the fallback when keyring_available() is True. Tests added for all three cases.
The fallback path exists for environments without a keyring (headless Linux, CI, Windows). Using os.chmod instead of os.fchmod removes the hasattr guard from the prior commit — one cross-platform call instead of a branching shim. Simpler test, same behavior.
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.
No description provided.