{"record":{"id":"0bf6534ebaa04d5b","repo":"plandex-ai/plandex","slug":"active-plan-not-found-for-plan-id-s-and-branch-s-0bf653","errorCode":null,"errorMessage":"active plan not found for plan ID %s and branch %s","messagePattern":"active plan not found for plan ID (.+?) and branch (.+?)","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"app/server/model/plan/build_whole_file.go","lineNumber":34,"sourceCode":"\n\t\"github.com/sashabaranov/go-openai\"\n)\n\nfunc (fileState *activeBuildStreamFileState) buildWholeFileFallback(buildCtx context.Context, proposedContent string, desc string, comments string, sessionId string) (string, error) {\n\tauth := fileState.auth\n\tfilePath := fileState.filePath\n\tclients := fileState.clients\n\tauthVars := fileState.authVars\n\tplanId := fileState.plan.Id\n\tbranch := fileState.branch\n\toriginalFile := fileState.preBuildState\n\tconfig := fileState.settings.GetModelPack().GetWholeFileBuilder()\n\n\tactivePlan := GetActivePlan(planId, branch)\n\n\tif activePlan == nil {\n\t\tlog.Printf(\"Active plan not found for plan ID %s and branch %s\\n\", planId, branch)\n\t\tfileState.onBuildFileError(fmt.Errorf(\"active plan not found for plan ID %s and branch %s\", planId, branch))\n\t\treturn \"\", fmt.Errorf(\"active plan not found for plan ID %s and branch %s\", planId, branch)\n\t}\n\n\tbaseModelConfig := config.GetBaseModelConfig(authVars, fileState.settings, fileState.orgUserConfig)\n\n\toriginalFileWithLineNums := shared.AddLineNums(originalFile)\n\tproposedContentWithLineNums := shared.AddLineNums(proposedContent)\n\n\tsysPrompt, headNumTokens := prompts.GetWholeFilePrompt(filePath, originalFileWithLineNums, proposedContentWithLineNums, desc, comments)\n\n\tmessages := []types.ExtendedChatMessage{\n\t\t{\n\t\t\tRole: openai.ChatMessageRoleSystem,\n\t\t\tContent: []types.ExtendedChatMessagePart{\n\t\t\t\t{\n\t\t\t\t\tType: openai.ChatMessagePartTypeText,\n\t\t\t\t\tText: sysPrompt,\n\t\t\t\t},","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/model/plan/build_whole_file.go#L16-L52","documentation":"buildWholeFileFallback's first error return when GetActivePlan(planId, branch) is nil — the whole-file builder cannot proceed without the active plan context. The error is also passed to fileState.onBuildFileError.","triggerScenarios":"Whole-file build invoked with a planId/branch pair that has no registered active plan.","commonSituations":"Branch mismatch (e.g. empty or renamed branch), plan finished/cleared before the fallback runs, or caller passing a stale planId.","solutions":["Activate/register the plan before calling the whole-file builder","Log and verify planId and branch values at the call site","Fix race conditions where plan cleanup runs before build fallback"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if GetActivePlan(planId, branch) == nil {\n    return fmt.Errorf(\"cannot run whole-file build: plan %s inactive on %s\", planId, branch)\n}","typeGuard":"func hasActivePlan(planId, branch string) bool { return GetActivePlan(planId, branch) != nil }","tryCatchPattern":"out, err := buildWholeFileFallback(...)\nif err != nil && strings.Contains(err.Error(), \"active plan not found\") {\n    // recreate/activate plan and retry, or surface a user-facing plan-state error\n}","preventionTips":["Check plan activation before invoking fallback builds","Avoid concurrent plan removal during active builds","Pass the correct (non-empty) branch identifier"],"tags":["go","state","plan-lookup"],"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-14T00:17:10.932Z"}