{"record":{"id":"281895775408c684","repo":"larksuite/cli","slug":"keychain-is-corrupted","errorCode":null,"errorMessage":"keychain is corrupted","messagePattern":"keychain is corrupted","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/keychain/keychain_darwin.go","lineNumber":90,"sourceCode":"\tdefer cancel()\n\n\ttype result struct {\n\t\tkey []byte\n\t\terr error\n\t}\n\tresCh := make(chan result, 1)\n\tgo func() {\n\t\tdefer func() { recover() }()\n\n\t\tencodedKey, err := keyringGet(service, \"master.key\")\n\t\tif err == nil {\n\t\t\tkey, decodeErr := base64.StdEncoding.DecodeString(encodedKey)\n\t\t\tif decodeErr == nil && len(key) == masterKeyBytes {\n\t\t\t\tresCh <- result{key: key, err: nil}\n\t\t\t\treturn\n\t\t\t}\n\t\t\t// Key is found but invalid or corrupted\n\t\t\tresCh <- result{key: nil, err: errors.New(\"keychain is corrupted\")}\n\t\t\treturn\n\t\t} else if !errors.Is(err, keyring.ErrNotFound) {\n\t\t\t// Not ErrNotFound, which means access was denied or blocked by the system\n\t\t\tresCh <- result{key: nil, err: errKeychainBlocked}\n\t\t\treturn\n\t\t}\n\n\t\t// If ErrNotFound, check if we are allowed to create a new key\n\t\tif !allowCreate {\n\t\t\t// Creation not allowed (e.g., during Get operation), return error\n\t\t\tresCh <- result{key: nil, err: errNotInitialized}\n\t\t\treturn\n\t\t}\n\n\t\t// It's the first time and creation is allowed (Set operation), generate a new key\n\t\tkey := make([]byte, masterKeyBytes)\n\t\tif _, randErr := rand.Read(key); randErr != nil {\n\t\t\tresCh <- result{key: nil, err: randErr}","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/internal/keychain/keychain_darwin.go#L72-L108","documentation":"Raised inside the goroutine that fetches the master key from the macOS keychain: the `master.key` item was found, but its value either failed base64 decoding or did not decode to exactly masterKeyBytes. A generic corruption sentinel - the secret exists but is unusable, so stored credentials cannot be decrypted.","triggerScenarios":"Thrown at internal/keychain/keychain_darwin.go:90 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Delete the corrupted `master.key` keychain item and run any auth command to generate a fresh master key (previously stored secrets must be re-created)"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}