{"record":{"id":"25988461926f9d2f","repo":"plandex-ai/plandex","slug":"error-writing-auth-auth-not-loaded","errorCode":null,"errorMessage":"error writing auth: auth not loaded","messagePattern":"error writing auth: auth not loaded","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/auth/state.go","lineNumber":91,"sourceCode":"\n\tbytes, err := json.Marshal(accounts)\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error marshalling accounts: %v\", err)\n\t}\n\n\terr = os.WriteFile(fs.HomeAccountsPath, bytes, os.ModePerm)\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error writing accounts: %v\", err)\n\t}\n\n\treturn nil\n}\n\nfunc writeCurrentAuth() error {\n\tif Current == nil {\n\t\treturn fmt.Errorf(\"error writing auth: auth not loaded\")\n\t}\n\n\tbytes, err := json.Marshal(Current)\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error marshalling auth: %v\", err)\n\t}\n\n\terr = os.WriteFile(fs.HomeAuthPath, bytes, os.ModePerm)\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error writing auth: %v\", err)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":73,"sourceCodeEnd":108,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/auth/state.go#L73-L108","documentation":"Sentinel guard in writeCurrentAuth: the package-global Current session pointer is nil, so there is no loaded auth session to persist. Callers invoked writeCurrentAuth (directly or via setAuth/RefreshAuth) before loadCurrentAuth/initialization ran.","triggerScenarios":"Thrown at app/cli/auth/state.go:91 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure auth state is loaded (loadCurrentAuth) before any write path runs","Guard callers so they skip persisting when the user is not signed in","Initialize Current to a non-nil session at CLI startup"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}