{"record":{"id":"68e737bb3bd51892","repo":"git-ecosystem/git-credential-manager","slug":"unknown-error","errorCode":null,"errorMessage":"Unknown error.","messagePattern":"Unknown error\\.","errorType":"error_code","errorClass":"InteropException","httpStatus":null,"severity":"error","filePath":"src/Core/Interop/MacOS/Native/SecurityFramework.cs","lineNumber":158,"sourceCode":"                    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    {\n        public uint Count;\n        public IntPtr Tag; // uint* (SecKeychainAttrType*)","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/Core/Interop/MacOS/Native/SecurityFramework.cs#L140-L176","documentation":"ThrowIfError's default case throws InteropException with the generic 'Unknown error.' message when a macOS Security.framework status code has no explicit mapping. It preserves the raw error code so the underlying Sec status can still be diagnosed.","triggerScenarios":"Any Security.framework call (SecItemAdd, SecItemCopyMatching, SecItemDelete, etc.) returning an errSec status code not handled by the switch in ThrowIfError — e.g. errSecMissingEntitlement, errSecNotAvailable, or other unmapped statuses.","commonSituations":"Running on locked-down CI with no keychain access (errSecMissingEntitlement surfacing as unknown); keychain locked or unavailable in headless/SSH sessions; corrupt keychain; unusual macOS versions returning newer status codes.","solutions":["Inspect the InteropException's raw error code and map it to the errSec constant (compare with Apple's Security framework docs).","Ensure a keychain is available and unlocked in the environment (headless: create/unlock a keychain with `security create-keychain` / `security unlock-keychain`).","Configure an alternative credential store (cache, plaintext file, GPG/pass) via GCM's credential.credentialStore setting.","If a common errSec code recurs, extend the switch in ThrowIfError with an explicit case."],"exampleFix":"// before\ncase ErrorSecNoSuchAttr:\n    throw new InteropException(\"The attribute does not exist.\", error);\ndefault:\n    throw new InteropException(defaultErrorMessage, error);\n// after\ncase ErrorSecNoSuchAttr:\n    throw new InteropException(\"The attribute does not exist.\", error);\ncase ErrorSecMissingEntitlement:\n    throw new InteropException(\"Missing keychain entitlement (check hardening/entitlements).\", error);\ndefault:\n    throw new InteropException($\"Unknown security error {error}.\", error);","handlingStrategy":"fallback","validationCode":"// Check a usable keychain exists before invoking the helper:\n// security show-keychain-info  (fails if no default/unlocked keychain)","typeGuard":"static bool HasUsableKeychain() =>\n    Environment.OSVersion.Platform == PlatformID.MacOSX &&\n    Run(\"security\", \"show-keychain-info\") == 0;","tryCatchPattern":"try { cred = keychainStore.Get(...); }\ncatch (InteropException ex)\n{ log.Warn($\"Keychain error {ex.ErrorCode}; falling back to cache store\"); cred = cacheStore.Get(...); }","preventionTips":["In CI/headless macOS, create and unlock a dedicated keychain before running git.","Configure credential.credentialStore explicitly instead of relying on defaults.","Log the raw error code from InteropException to map unmapped errSec statuses.","Keep the keychain from auto-locking during long operations."],"tags":["macos","keychain","interop","unknown-error-code"],"backgroundTag":"internal-invariant-violation","analyzedSha":"e8ce762cd04b4100ae637b5fbf39ef9d0a96561e","analyzedAt":"2026-09-11T17:15:08.753Z","contentChangedAt":"2026-09-11T17:15:08.753Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}