{"record":{"id":"7b7aa8d4fb6ce402","repo":"plandex-ai/plandex","slug":"error-marshalling-accounts-v","errorCode":null,"errorMessage":"error marshalling accounts: %v","messagePattern":"error marshalling accounts: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/auth/state.go","lineNumber":77,"sourceCode":"\t}\n\n\tfound := false\n\tfor i, account := range accounts {\n\t\tif account.UserId == toStore.UserId {\n\t\t\taccounts[i] = toStore\n\t\t\tfound = true\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif !found {\n\t\taccounts = append(accounts, toStore)\n\t}\n\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","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/auth/state.go#L59-L95","documentation":"Fires in storeAccount when json.Marshal fails to serialize the in-memory accounts slice to JSON before it is persisted to fs.HomeAccountsPath. Marshal of []Account should not fail under normal data, so this signals corrupted account structs (e.g. unsupported types via custom MarshalJSON).","triggerScenarios":"Thrown at app/cli/auth/state.go:77 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped marshal error to find the offending account field type","Fix any custom MarshalJSON implementations on the Account type","Verify no unmarshalable values (channels, funcs, cycles) enter the accounts slice"],"exampleFix":null,"handlingStrategy":"try-catch","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-14T00:17:10.932Z"}