{"record":{"id":"58bfe4f5da88d7f8","repo":"git-ecosystem/git-credential-manager","slug":"errorsecnosuchattr","errorCode":"ErrorSecNoSuchAttr","errorMessage":"The attribute does not exist.","messagePattern":"The attribute does not exist\\.","errorType":"error_code","errorClass":"InteropException","httpStatus":null,"severity":"error","filePath":"src/Core/Interop/MacOS/Native/SecurityFramework.cs","lineNumber":156,"sourceCode":"            {\n                case OK:\n                    return;\n                case ErrorSecNoSuchKeychain:\n                    throw new InteropException(\"The keychain does not exist.\", error);\n                case ErrorSecInvalidKeychain:\n                    throw new InteropException(\"The keychain is not valid.\", error);\n                case ErrorSecAuthFailed:\n                    throw new InteropException(\"Authorization/Authentication failed.\", error);\n                case ErrorSecDuplicateItem:\n                    throw new InteropException(\"The item already exists.\", error);\n                case ErrorSecItemNotFound:\n                    throw new InteropException(\"The item cannot be found.\", error);\n                case ErrorSecInteractionNotAllowed:\n                    throw new InteropException(\"Interaction with the Security Server is not allowed.\", error);\n                case ErrorSecInteractionRequired:\n                    throw new InteropException(\"User interaction is required.\", error);\n                case ErrorSecNoSuchAttr:\n                    throw new InteropException(\"The attribute does not exist.\", error);\n                default:\n                    throw new InteropException(defaultErrorMessage, error);\n            }\n        }\n    }\n\n    [Flags]\n    public enum SessionAttributeBits\n    {\n        SessionIsRoot = 0x0001,\n        SessionHasGraphicAccess = 0x0010,\n        SessionHasTty = 0x0020,\n        SessionIsRemote = 0x1000,\n    }\n\n    [StructLayout(LayoutKind.Sequential)]\n    public struct SecKeychainAttributeInfo\n    {","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/Core/Interop/MacOS/Native/SecurityFramework.cs#L138-L174","documentation":"ThrowIfError maps macOS Security.framework (errSecNoSuchAttr) status codes to InteropException. This case fires when a keychain item attribute lookup asks for an attribute that the item does not carry. The Security framework returns the raw status and GCM converts it into a typed exception with a human-readable message.","triggerScenarios":"Calling a keychain attribute query (e.g. SecItemCopyMatching requesting specific attributes) against an item that lacks the requested attribute tag, so the OS returns ErrorSecNoSuchAttr.","commonSituations":"Reading credentials from keychain items created by other tools that store fewer/different attributes; querying attributes like account or label on items that only hold password data; macOS version differences in which attributes items carry.","solutions":["Request fewer attributes in the SecItem query, or tolerate a null value for optional attributes.","Inspect the keychain item (Keychain Access or `security find-generic-password`) to see which attributes it actually has.","Recreate the credential via GCM so all expected attributes are populated.","Catch InteropException and fall back to re-prompting for credentials."],"exampleFix":"// before\nvar query = new SecRecord { Generic = service, Account = account, Label = \"GCM\" };\nvar attrs = item.Attributes;\n// after\nvar attrs = item.Attributes;\nstring label = attrs.TryGetValue(SecAttribute.Label, out var l) ? l : null; // treat attribute as optional","handlingStrategy":"try-catch","validationCode":"if (expectedAttributes.Any(a => !item.Attributes.ContainsKey(a)))\n    // skip or request fewer attributes before calling the keychain API","typeGuard":"bool TryGetAttr(IDictionary<string,string> attrs, string key, out string value) { value = null; return attrs != null && attrs.TryGetValue(key, out value); }","tryCatchPattern":"try { cred = keychain.GetCredential(service, account); }\ncatch (InteropException ex) when (ex.Message.Contains(\"attribute does not exist\"))\n{ cred = new Credential(service, account, password: null); }","preventionTips":["Treat all keychain attributes except the password data as optional.","Inspect items with `security find-generic-password` before relying on specific attributes.","Write credentials through GCM so the expected attribute set is consistent."],"tags":["macos","keychain","interop","security-framework"],"backgroundTag":"resource-not-found","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"}