{"record":{"id":"064090a552f62973","repo":"larksuite/cli","slug":"registry-set-failed-w","errorCode":null,"errorMessage":"registry set failed: %w","messagePattern":"registry set failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/keychain/keychain_windows.go","lineNumber":170,"sourceCode":"\tplain, err := dpapiUnprotect(blob, entropy)\n\tif err != nil {\n\t\treturn \"\", false\n\t}\n\treturn string(plain), true\n}\n\n// registrySet stores a string value in the registry under the given service and account.\nfunc registrySet(service, account string, protected []byte) error {\n\tkeyPath := registryPathForService(service)\n\tk, _, err := registry.CreateKey(registry.CURRENT_USER, keyPath, registry.SET_VALUE)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"registry create/open failed: %w\", err)\n\t}\n\tdefer k.Close()\n\n\tb64 := base64.StdEncoding.EncodeToString(protected)\n\tif err := k.SetStringValue(valueNameForAccount(account), b64); err != nil {\n\t\treturn fmt.Errorf(\"registry set failed: %w\", err)\n\t}\n\treturn nil\n}\n\n// registryRemove deletes a value from the registry under the given service and account.\nfunc registryRemove(service, account string) error {\n\tkeyPath := registryPathForService(service)\n\tk, err := registry.OpenKey(registry.CURRENT_USER, keyPath, registry.SET_VALUE)\n\tif err != nil {\n\t\treturn nil\n\t}\n\tdefer k.Close()\n\t_ = k.DeleteValue(valueNameForAccount(account))\n\treturn nil\n}\n","sourceCodeStart":152,"sourceCodeEnd":186,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/internal/keychain/keychain_windows.go#L152-L186","documentation":"This error wraps a failure to write the (already DPAPI-protected, base64-encoded) credential string into the opened registry value. The key was created/opened successfully but k.SetStringValue failed, so the credential store write did not complete. The %w preserves the underlying Windows error for diagnosis.","triggerScenarios":"platformSet -> registrySet: after a successful CreateKey, k.SetStringValue(valueNameForAccount(account), b64) returns an error.","commonSituations":"Key handle opened read-only due to weird ACL inheritance despite SET_VALUE request; quota or policy limits on registry value size; endpoint security intercepting writes to credential-like values; key deleted between open and set by another process/cleanup tool.","solutions":["Read the wrapped cause for the specific Win32 error and map it (access denied vs. invalid handle).","Check ACLs on the HKCU\\Software key path and ensure the current user has Set Value permission.","Exclude the CLI's registry path from security software that blocks credential-storage writes.","Retry the auth/store operation; if it persists, delete the stale key and let the CLI recreate it."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := keychain.Set(service, account, secret); err != nil {\n    if strings.Contains(err.Error(), \"registry set failed\") {\n        // key opened but write rejected: ACL/security software; advise cleanup + retry\n        return fmt.Errorf(\"registry write rejected, check ACLs/AV on HKCU key: %w\", err)\n    }\n    return err\n}","preventionTips":["Confirm user ACLs grant Set Value on the CLI's registry subtree.","Exclude credential-storage registry paths from security software.","Delete stale keys after version upgrades if writes keep failing.","Avoid running multiple store writers concurrently on the same key."],"tags":["windows","registry","keychain","permissions"],"backgroundTag":"registry-write-failed","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"}