{"record":{"id":"6e2b0b14a3462545","repo":"sipeed/picoclaw","slug":"failed-to-save-credentials-w","errorCode":null,"errorMessage":"failed to save credentials: %w","messagePattern":"failed to save credentials: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/picoclaw/internal/auth/helpers.go","lineNumber":54,"sourceCode":"\nfunc authLoginOpenAI(useDeviceCode bool, noBrowser bool) error {\n\tcfg := auth.OpenAIOAuthConfig()\n\n\tvar cred *auth.AuthCredential\n\tvar err error\n\n\tif useDeviceCode {\n\t\tcred, err = auth.LoginDeviceCode(cfg)\n\t} else {\n\t\tcred, err = auth.LoginBrowserWithOptions(cfg, auth.LoginBrowserOptions{NoBrowser: noBrowser})\n\t}\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"login failed: %w\", err)\n\t}\n\n\tif err = auth.SetCredential(\"openai\", cred); err != nil {\n\t\treturn fmt.Errorf(\"failed to save credentials: %w\", err)\n\t}\n\n\tappCfg, err := internal.LoadConfig()\n\tif err == nil {\n\t\t// Update or add openai in ModelList\n\t\tfoundOpenAI := false\n\t\tfor i := range appCfg.ModelList {\n\t\t\tif isOpenAIModel(appCfg.ModelList[i]) {\n\t\t\t\tappCfg.ModelList[i].AuthMethod = \"oauth\"\n\t\t\t\tfoundOpenAI = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\t// If no openai in ModelList, add it\n\t\tif !foundOpenAI {\n\t\t\tappCfg.ModelList = append(appCfg.ModelList, &config.ModelConfig{\n\t\t\t\tModelName:  \"gpt-5.4\",","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/cmd/picoclaw/internal/auth/helpers.go#L36-L72","documentation":"Context wrapper in authLoginOpenAI around auth.SetCredential: the OAuth login itself succeeded and produced a credential, but persisting it to the local auth store failed — typically an unwritable credentials file/path or a serialization problem. The token exists only in memory and is lost when this returns.","triggerScenarios":"Thrown at cmd/picoclaw/internal/auth/helpers.go:54 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check write permissions on the auth store path and its parent directory","Ensure the store file is not locked or corrupted; remove and re-login if it is","Verify disk space in the config directory","Retry the login after fixing permissions — the flow will mint a fresh token and save it"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","contentChangedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}