{"record":{"id":"ce3a7304003b6985","repo":"plandex-ai/plandex","slug":"active-plan-not-found","errorCode":null,"errorMessage":"active plan not found","messagePattern":"active plan not found","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"app/server/model/plan/build_load.go","lineNumber":168,"sourceCode":"\t})\n\n\tstate.modelContext = modelContext\n\tstate.settings = settings\n\tstate.orgUserConfig = orgUserConfig\n\n\treturn pendingBuildsByPath, nil\n}\n\nfunc (state *activeBuildStreamFileState) loadBuildFile(activeBuild *types.ActiveBuild) error {\n\tcurrentOrgId := state.currentOrgId\n\tplanId := state.plan.Id\n\tbranch := state.branch\n\tfilePath := state.filePath\n\n\tactivePlan := GetActivePlan(planId, branch)\n\n\tif activePlan == nil {\n\t\treturn fmt.Errorf(\"active plan not found\")\n\t}\n\n\tconvoMessageId := activeBuild.ReplyId\n\n\tparser, lang, fallbackParser, fallbackLang := syntax.GetParserForPath(filePath)\n\n\tif parser != nil {\n\t\tvalidationRes, err := syntax.ValidateWithParsers(activePlan.Ctx, lang, parser, fallbackLang, fallbackParser, state.preBuildState)\n\t\tif err != nil {\n\t\t\tlog.Printf(\" error validating original file syntax: %v\\n\", err)\n\t\t\treturn fmt.Errorf(\"error validating original file syntax: %v\", err)\n\t\t}\n\n\t\tstate.language = validationRes.Lang\n\t\tstate.parser = validationRes.Parser\n\n\t\tstate.builderRun.Lang = string(validationRes.Lang)\n","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/model/plan/build_load.go#L150-L186","documentation":"loadBuildFile looks up the in-memory active plan for (planId, branch) via GetActivePlan and fails with this error when no active plan is registered. The active plan map only contains plans whose build/stream is currently tracked in this process, so a miss means the plan was never registered, was already completed/cleaned up, or the process restarted.","triggerScenarios":"loadBuildFile is called (via execPlanBuild) with a planId/branch pair that has no entry in the active plan registry: the plan finished and was removed, the server restarted mid-build, the branch name is wrong or changed, or the active plan was evicted due to an earlier error.","commonSituations":"Resuming a build after an app deploy/restart (in-memory state lost); a second build stream racing with a completed one on the same branch; a client passing a stale plan ID or branch; plans cleaned up by a timeout/manager goroutine.","solutions":["Confirm the plan build for this planId+branch was actually started in the current process (call the plan-build start/init path before execPlanBuild).","Check for server restarts or multiple replicas — route the build to the instance that holds the active plan, or persist active plans.","Verify the branch name matches the branch used when the active plan was created.","Log the contents of the active plan registry for the planId to see when/why the entry disappeared.","Add/keep-alive registration: re-create the active plan via UpdateActivePlan before loading build files."],"exampleFix":"// before\nactivePlan := GetActivePlan(planId, branch)\nif activePlan == nil {\n    return fmt.Errorf(\"active plan not found\")\n}\n// after\nactivePlan := GetActivePlan(planId, branch)\nif activePlan == nil {\n    return fmt.Errorf(\"active plan not found for plan %s branch %s (was it completed or lost on restart?)\", planId, branch)\n}","handlingStrategy":"validation","validationCode":"if GetActivePlan(planId, branch) == nil {\n    return fmt.Errorf(\"no active plan for %s/%s — start the plan build first\", planId, branch)\n}","typeGuard":"func hasActivePlan(planId, branch string) bool {\n    return GetActivePlan(planId, branch) != nil\n}","tryCatchPattern":null,"preventionTips":["Always start/register the active plan (UpdateActivePlan) in the same process before loading build files.","Avoid restarting servers or failing over mid-build; persist active plans or make builds resumable.","Route build requests to the replica that owns the plan (sticky routing) in multi-instance deployments.","Double-check the branch name matches the one the plan was started with.","Treat plan completion/cleanup as terminal — don't re-issue build-file loads for finished plans."],"tags":["state","in-memory","plan","race-condition"],"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"}