{"record":{"id":"38f8667d81bdd6c0","repo":"plandex-ai/plandex","slug":"no-current-plan","errorCode":null,"errorMessage":"no current plan","messagePattern":"no current plan","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/lib/current.go","lineNumber":176,"sourceCode":"\n\t\tif err != nil {\n\t\t\tterm.OutputErrorAndExit(\"error loading current branch: %v\", err)\n\t\t}\n\n\t\tif CurrentBranch == \"\" {\n\t\t\terr = WriteCurrentBranch(\"main\")\n\n\t\t\tif err != nil {\n\t\t\t\tterm.OutputErrorAndExit(\"error setting current branch: %v\", err)\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc loadCurrentBranch() error {\n\t// Load plan-specific settings\n\tif CurrentPlanId == \"\" {\n\t\treturn fmt.Errorf(\"no current plan\")\n\t}\n\n\tpath := filepath.Join(HomeCurrentProjectDir, CurrentPlanId, \"settings-v2.json\")\n\n\t// Check if the file exists\n\t_, err := os.Stat(path)\n\n\tif os.IsNotExist(err) {\n\t\treturn nil\n\t} else if err != nil {\n\t\treturn fmt.Errorf(\"error checking if settings-v2.json exists: %v\", err)\n\t}\n\n\tfileBytes, err := os.ReadFile(path)\n\tif err != nil {\n\t\tterm.OutputErrorAndExit(\"error reading settings-v2.json: %v\", err)\n\t}\n","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/lib/current.go#L158-L194","documentation":"loadCurrentBranch requires a currently selected plan. If CurrentPlanId is empty (no plan has been created/selected in this workspace), it returns 'no current plan' instead of reading plan-specific settings-v2.json.","triggerScenarios":"Calling MustLoadCurrentPlan (which calls loadCurrentBranch) when CurrentPlanId == \"\" — i.e. before any plan is created or after the current-plan selection was never initialized in this project directory.","commonSituations":"Running a plan-dependent CLI command in a fresh project without creating a plan first; cleared/missing local state; running from a directory where plan selection was never saved; corrupted local config wiping CurrentPlanId.","solutions":["Create a new plan with the CLI's plan-creation command","Select/switch to an existing plan so CurrentPlanId is set","Check the current-project state directory to confirm any plan exists","Guard the command: skip plan-dependent logic when no plan is selected"],"exampleFix":"// before\ncurrent, err := MustLoadCurrentPlan()\n// after: check plan exists first\nif CurrentPlanId == \"\" {\n    term.OutputErrorAndExit(\"no plan selected — run the plan creation command first\")\n}\ncurrent, err := MustLoadCurrentPlan()","handlingStrategy":"validation","validationCode":"if CurrentPlanId == \"\" {\n    return fmt.Errorf(\"no plan selected — create or select a plan first\")\n}","typeGuard":null,"tryCatchPattern":"current, err := MustLoadCurrentPlan()\nif err != nil && err.Error() == \"no current plan\" {\n    return promptCreateOrSelectPlan() // recover by onboarding\n}","preventionTips":["Always create/select a plan before running plan-dependent commands","Check CurrentPlanId at CLI entry for plan-requiring subcommands","Back up the local state directory to avoid losing plan selection"],"tags":["cli","plan","state","missing-config"],"backgroundTag":"no-current-plan","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}