{"record":{"id":"1bd9422d952206cb","repo":"plandex-ai/plandex","slug":"active-plan-not-found-for-plan-s-and-branch-s","errorCode":null,"errorMessage":"active plan not found for plan %s and branch %s","messagePattern":"active plan not found for plan (.+?) and branch (.+?)","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"app/server/model/plan/commit_msg.go","lineNumber":34,"sourceCode":"\tshared \"plandex-shared\"\n\n\t\"github.com/sashabaranov/go-openai\"\n)\n\nfunc (state *activeTellStreamState) genPlanDescription() (*db.ConvoMessageDescription, *shared.ApiError) {\n\tauth := state.auth\n\tplan := state.plan\n\tplanId := plan.Id\n\tbranch := state.branch\n\tsettings := state.settings\n\tclients := state.clients\n\tauthVars := state.authVars\n\torgUserConfig := state.orgUserConfig\n\tconfig := settings.GetModelPack().CommitMsg\n\n\tactivePlan := GetActivePlan(planId, branch)\n\tif activePlan == nil {\n\t\tgo notify.NotifyErr(notify.SeverityError, fmt.Errorf(\"active plan not found for plan %s and branch %s\", planId, branch))\n\n\t\treturn nil, &shared.ApiError{\n\t\t\tType:   shared.ApiErrorTypeOther,\n\t\t\tStatus: http.StatusInternalServerError,\n\t\t\tMsg:    fmt.Sprintf(\"active plan not found for plan %s and branch %s\", planId, branch),\n\t\t}\n\t}\n\n\tbaseModelConfig := config.GetBaseModelConfig(authVars, settings, orgUserConfig)\n\n\tvar sysPrompt string\n\tvar tools []openai.Tool\n\tvar toolChoice *openai.ToolChoice\n\n\tif baseModelConfig.PreferredOutputFormat == shared.ModelOutputFormatXml {\n\t\tsysPrompt = prompts.SysDescribeXml\n\t} else {\n\t\tsysPrompt = prompts.SysDescribe","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/model/plan/commit_msg.go#L16-L52","documentation":"genPlanDescription needs the active plan (for its context, session ID, and cancellation scope) before generating a plan/commit description via the LLM. When GetActivePlan returns nil for the plan ID + branch, it notifies and returns a 500 ApiError. The description cannot be generated without the live plan session.","triggerScenarios":"The tell stream that should have registered the active plan has ended (finished, errored, stopped, or deleted via DeleteActivePlan) before genPlanDescription runs; or the planId/branch pair passed to the stream does not match any registered active plan.","commonSituations":"Plan finished extremely fast and was deactivated before the description step; concurrent Stop request during streaming; using a stale planId after a server restart; branch name typo in the API call.","solutions":["Verify the planId and branch match the currently streaming plan (GET the plan's status first)","Retry the tell request so the plan is re-activated before description generation","Check server logs for an earlier Stop or DeleteActivePlan call for this plan","Report/persist a description fallback so a finished plan doesn't lose its commit message"],"exampleFix":"// before\ndesc, apiErr := state.genPlanDescription()\n// after: check the plan is still active first\nif modelPlan.GetActivePlan(planId, branch) == nil {\n    log.Println(\"plan no longer active; skipping description\")\n    return\n}\ndesc, apiErr := state.genPlanDescription()","handlingStrategy":"try-catch","validationCode":"// ensure plan is streaming before asking for a description\nresp, _ := http.Get(baseURL + \"/plans/\" + planId + \"/\" + branch + \"/status\")\n// only proceed if status indicates an active/streaming plan","typeGuard":null,"tryCatchPattern":"desc, apiErr := state.genPlanDescription()\nif apiErr != nil && strings.Contains(apiErr.Msg, \"active plan not found\") {\n    log.Printf(\"plan %s/%s deactivated before description; skipping\", planId, branch)\n    return\n}","preventionTips":["Don't stop or disconnect the plan mid-stream; descriptions are generated at stream end","Keep the plan active until the description step completes","Verify branch spelling in all API calls","Handle finished plans gracefully — description is not required for correctness"],"tags":["go","plan-state","internal-server-error"],"backgroundTag":"active-plan-not-found","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"}