{"record":{"id":"cbd665ad035e0f58","repo":"git-ecosystem/git-credential-manager","slug":"failed-to-search-for-credentials","errorCode":null,"errorMessage":"Failed to search for credentials","messagePattern":"Failed to search for credentials","errorType":"exception","errorClass":"InteropException","httpStatus":null,"severity":"error","filePath":"src/Core/Interop/Linux/SecretServiceCollection.cs","lineNumber":79,"sourceCode":"\r\n                queryAttrs = CreateSearchQuery(service, account);\r\n\r\n                SecretSchema schema = GetSchema();\r\n\r\n                // Execute search query and return all results\r\n                results = secret_service_search_sync(\r\n                    secService,\r\n                    ref schema,\r\n                    queryAttrs,\r\n                    SecretSearchFlags.SECRET_SEARCH_UNLOCK | SecretSearchFlags.SECRET_SEARCH_ALL,\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 search for credentials\", code, new Exception(message));\r\n                }\r\n\r\n                var credentials = new List<ICredential>();\r\n\r\n                GList* itemPtr = results;\r\n                while (itemPtr != null && itemPtr->data != IntPtr.Zero)\r\n                {\r\n                    SecretItem* item = (SecretItem*) itemPtr->data;\r\n\r\n                    // Although we've unlocked the collection during the search call,\r\n                    // an item can also be individually locked within a collection.\r\n                    // If the item is locked we should try and unlock it.\r\n                    if (secret_item_get_locked(item))\r\n                    {\r\n                        var toUnlockList = new GList\r\n                        {\r\n                            data = (IntPtr) item,\r\n                            next = IntPtr.Zero,\r","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/Core/Interop/Linux/SecretServiceCollection.cs#L61-L97","documentation":"Enumerate calls secret_service_search_sync (libsecret) to find matching credentials in the GNOME keyring / Secret Service. If the call returns a GError, the error code and message are wrapped in an InteropException with this fixed message and thrown, so the underlying D-Bus/keyring failure is preserved as the inner exception.","triggerScenarios":"GetAccounts() or Get(service/account) when the Secret Service search D-Bus call fails: keyring daemon not running, service locked, schema/attribute mismatch errors returned by the daemon.","commonSituations":"Running on a system without gnome-keyring or a Secret Service implementation (bare servers, WSL without keyring integration); keyring daemon crashed; searching a collection that does not exist.","solutions":["Read the inner Exception message (the GError message) for the real cause from the D-Bus daemon","Ensure a Secret Service provider is running (e.g. start gnome-keyring-daemon or gnome-keyring --components)","Unlock the keyring/session (e.g. via seahorse or logging into the desktop session)","Verify you are running in a desktop session with D-Bus session bus available (DBUS_SESSION_BUS_ADDRESS set)"],"exampleFix":"// before\nvar accounts = collection.GetAccounts(); // InteropException with hidden D-Bus error\n// after\ntry { var accounts = collection.GetAccounts(); }\ncatch (InteropException ex) { Log(ex.InnerException?.Message ?? ex.Message); }","handlingStrategy":"try-catch","validationCode":"bool SecretServiceAvailable() =>\n    Environment.GetEnvironmentVariable(\"DBUS_SESSION_BUS_ADDRESS\") != null;\nif (!SecretServiceAvailable()) throw new InvalidOperationException(\"No D-Bus session for Secret Service\");","typeGuard":null,"tryCatchPattern":"try { return collection.GetAccounts(); }\ncatch (InteropException ex) { throw new CredentialStoreException($\"Keyring search failed: {ex.InnerException?.Message}\", ex); }","preventionTips":["Ensure gnome-keyring/Secret Service is installed and running on target machines","Always read the inner exception for the real D-Bus error","Run in a desktop or D-Bus-enabled session when touching the keyring","Pre-flight check the keyring daemon health at app startup"],"tags":["linux","keyring","dbus","credentials"],"backgroundTag":"database-query-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"}