You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue: keyring.set_value Returns None Using Default Backend
When using keyring.set_value() to store a password without explicitly specifying a backend, the default backend selected is keyring.backends.null.Keyring, which results in the value being stored as None. This happens despite the system having a valid keyring service (Seahorse) managing secrets.
However, when I manually specify the SecretService backend in the code, the password is stored and retrieved correctly. The default backend should ideally select a working backend without requiring manual intervention.
How I Get This Error
Steps to encounter the behavior:
Use the following code snippet to store and retrieve a secret using the default backend:
importkeyringaskrAPP_NAME='Keyring-test'TEST_KEY="test_key"test_value="Hello, I am keyring test value"# Set a value using the default backendkr.set_password(APP_NAME, TEST_KEY, test_value)
# Retrieve the valueretrieved_value=kr.get_password(APP_NAME, TEST_KEY)
print(f"Retrieved value: {retrieved_value}")
Run the code on a system using Gnome 43.9 (Wayland) with Seahorse handling secrets.
Observe that retrieved_value is None, despite expecting it to return the stored test_value.
Now, try the same code with a specific backend (which works correctly):
importkeyringaskrfromkeyring.backendsimportSecretServiceAPP_NAME='Keyring-test'TEST_KEY="test_key_with_specific_backend"test_value="Hello, I am keyring test value with specific backend"# Set a specific backendbackend=SecretService.Keyring()
kr.set_keyring(backend)
# Store the value using the specific backendkr.set_password(APP_NAME, TEST_KEY, test_value)
# Retrieve the valueretrieved_value=kr.get_password(APP_NAME, TEST_KEY)
print(f"Retrieved value: {retrieved_value}")
Observe that when using the specific backend, the value is stored and retrieved correctly.
Expected Behavior
The keyring library should automatically select a functional backend (e.g., SecretService or Gnome Keyring) when no backend is explicitly specified. The stored value should be retrievable using the default backend configuration.
Environment
OS: debian 12 (xfce as desktop environment)
Backend: Seahorse (handles secrets)
Keyring Version: keyring 25.3.0
Additional Context
Here’s the result I observed with the default and specific backends:
--- Setting and Retrieving Value Without Specific Backend ---
Using backend: keyring.backends.null.Keyring (priority: -1)
Password set successfully for key: test_key
Using backend: keyring.backends.null.Keyring (priority: -1)
Value retrieved for key 'test_key': None
--- Setting and Retrieving Value With Specific Backend ---
Current backend: keyring.backends.SecretService.Keyring (priority: 5)
Password set successfully for key: test_key_with_specific_backend
Retrieved password: Hello, I am keyring test value with specific backend
The issue occurs when keyring.get_keyring() defaults to keyring.backends.null.Keyring, which has a priority of -1 and does not store secrets. Manually selecting SecretService.Keyring resolves the issue.
Based on the priorities reported, keyring.backends.SecretService.Keyring should be the default backend. Moreover, the null.Keyring should only be selected when specifically configured, such as through Disabling Keyring. You should double-check that you don't have that environment variable set or have the null.Keyringconfigured.
Issue:
keyring.set_value
ReturnsNone
Using Default BackendWhen using
keyring.set_value()
to store a password without explicitly specifying a backend, the default backend selected iskeyring.backends.null.Keyring
, which results in the value being stored asNone
. This happens despite the system having a valid keyring service (Seahorse) managing secrets.However, when I manually specify the
SecretService
backend in the code, the password is stored and retrieved correctly. The default backend should ideally select a working backend without requiring manual intervention.How I Get This Error
Steps to encounter the behavior:
Use the following code snippet to store and retrieve a secret using the default backend:
Run the code on a system using Gnome 43.9 (Wayland) with Seahorse handling secrets.
Observe that
retrieved_value
isNone
, despite expecting it to return the storedtest_value
.Now, try the same code with a specific backend (which works correctly):
Observe that when using the specific backend, the value is stored and retrieved correctly.
Expected Behavior
The
keyring
library should automatically select a functional backend (e.g.,SecretService
orGnome Keyring
) when no backend is explicitly specified. The stored value should be retrievable using the default backend configuration.Environment
Additional Context
Here’s the result I observed with the default and specific backends:
The issue occurs when
keyring.get_keyring()
defaults tokeyring.backends.null.Keyring
, which has a priority of-1
and does not store secrets. Manually selectingSecretService.Keyring
resolves the issue.List of the backends :
The text was updated successfully, but these errors were encountered: