{"record":{"id":"06ccd1ceed4d6d6d","repo":"git-ecosystem/git-credential-manager","slug":"failed-to-store-credentials","errorCode":null,"errorMessage":"Failed to store credentials","messagePattern":"Failed to store credentials","errorType":"exception","errorClass":"InteropException","httpStatus":null,"severity":"error","filePath":"src/Core/Interop/Linux/SecretServiceCollection.cs","lineNumber":187,"sourceCode":"\r\n                SecretSchema schema = GetSchema();\r\n\r\n                // Store the secret with the associated attributes\r\n                bool result = secret_service_store_sync(\r\n                    secService,\r\n                    ref schema,\r\n                    attributes,\r\n                    null,\r\n                    fullServiceName, // Use full service name as label\r\n                    secretValue,\r\n                    IntPtr.Zero,\r\n                    out error);\r\n\r\n                if (error != null)\r\n                {\r\n                    int code = error->code;\r\n                    string message = Marshal.PtrToStringAuto(error->message)!;\r\n                    throw new InteropException(\"Failed to store credentials\", code, new Exception(message));\r\n                }\r\n\r\n                if (!result)\r\n                {\r\n                    throw new InteropException(\"Failed to store credentials\", -1);\r\n                }\r\n            }\r\n            finally\r\n            {\r\n                if (attributes != null) g_hash_table_destroy(attributes);\r\n                if (secretValue != null) secret_value_unref(secretValue);\r\n                if (error != null) g_error_free(error);\r\n            }\r\n        }\r\n\r\n        public unsafe bool Remove(string service, string account)\r\n        {\r\n            GHashTable* attributes = null;\r","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/Core/Interop/Linux/SecretServiceCollection.cs#L169-L205","documentation":"AddOrUpdate calls secret_password_store_sync to write a credential to the Secret Service. If the call returns a GError it throws an InteropException carrying the daemon's error code and message (inner exception), indicating the credential could not be stored.","triggerScenarios":"Calling AddOrUpdate when the store D-Bus call fails: keyring locked/unavailable, invalid attributes, no default collection, disk full, or daemon rejection.","commonSituations":"Storing into a locked or missing keyring on a headless server; no default keyring created yet; gnome-keyring not running; schema attribute values containing unsupported characters.","solutions":["Read the inner exception (GError message) for the daemon's concrete failure reason","Ensure gnome-keyring daemon is running and a default collection exists and is unlocked","Create/unlock the default keyring (seahorse or gnome-keyring-daemon --unlock) before writing","Retry after unlocking; validate that the key/value and attribute strings are non-null and well-formed"],"exampleFix":"// before\ncollection.AddOrUpdate(service, account, secret); // fails if keyring locked\n// after\nEnsureKeyringUnlocked(); // prompt / gnome-keyring-daemon --unlock\ncollection.AddOrUpdate(service, account, secret);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(service) || string.IsNullOrEmpty(account) || secret == null)\n    throw new ArgumentException(\"service, account and secret are required before storing\");\nEnsureKeyringRunningAndUnlocked();","typeGuard":null,"tryCatchPattern":"try { collection.AddOrUpdate(service, account, secret); }\ncatch (InteropException ex) { throw new CredentialStoreException($\"Store failed: {ex.InnerException?.Message}\", ex); }","preventionTips":["Create and unlock the default keyring before first write","Validate key/value/attribute strings before calling","Keep gnome-keyring running and healthy on the host","Log the inner GError message to diagnose daemon rejections"],"tags":["linux","keyring","credentials","dbus"],"backgroundTag":"database-write-failed","analyzedSha":"e8ce762cd04b4100ae637b5fbf39ef9d0a96561e","analyzedAt":"2026-09-11T17:15:08.753Z","contentChangedAt":"2026-09-11T17:15:08.753Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}