{"record":{"id":"ce3977f285ce8457","repo":"plandex-ai/plandex","slug":"active-plan-not-found-for-plan-id-s-on-branch-s","errorCode":null,"errorMessage":"active plan not found for plan ID %s on branch %s","messagePattern":"active plan not found for plan ID (.+?) on branch (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/server/model/plan/tell_stream_error.go","lineNumber":267,"sourceCode":"\n\t\tactive.StreamDoneCh <- &shared.ApiError{\n\t\t\tType:   shared.ApiErrorTypeOther,\n\t\t\tStatus: http.StatusInternalServerError,\n\t\t\tMsg:    msg,\n\t\t}\n\t}\n\n\treturn onErrorResult{\n\t\tshouldContinueMainLoop: true,\n\t}\n}\n\nfunc (state *activeTellStreamState) onActivePlanMissingError() {\n\tplanId := state.plan.Id\n\tbranch := state.branch\n\tlog.Printf(\"Active plan not found for plan ID %s on branch %s\\n\", planId, branch)\n\tstate.onError(onErrorParams{\n\t\tstreamErr: fmt.Errorf(\"active plan not found for plan ID %s on branch %s\", planId, branch),\n\t\tstoreDesc: true,\n\t})\n}\n","sourceCodeStart":249,"sourceCodeEnd":271,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/model/plan/tell_stream_error.go#L249-L271","documentation":"onActivePlanMissingError in tell_stream_error.go centralizes handling for a missing in-memory active plan during an active tell stream. When any stream handler (processChunk, handleMissingFile, handleDescAndExecStatus, handleStreamFinished) finds GetActivePlan(planId, branch) nil, this method logs and routes the formatted 'active plan not found for plan ID %s on branch %s' error through state.onError with storeDesc=true so the description is persisted.","triggerScenarios":"Active plan evicted/removed mid-stream (stream finished on another path), branch identifier mismatch between stream start and chunk processing, concurrent stream-finish paths racing to clear the active plan, or server state loss.","commonSituations":"Double handling of a finished stream; client retries chunks after the active plan was cleaned up; branch name casing/prefix differs between registration and lookup.","solutions":["Check server logs for which handler triggered it and whether a prior finish already removed the plan","Ensure only one code path clears the active plan (guard with sync.Once or state flag)","Compare branch strings at stream start vs chunk processing","If caused by a stale client stream, close the connection instead of retrying"],"exampleFix":"// before\nfunc (state *activeTellStreamState) onActivePlanMissingError() {\n    state.onError(onErrorParams{\n        streamErr: fmt.Errorf(\"active plan not found for plan ID %s on branch %s\", planId, branch),\n        storeDesc: true,\n    })\n}\n// after\nfunc (state *activeTellStreamState) onActivePlanMissingError() {\n    if state.cleanedUp.Load() { // already finished; don't double-handle\n        return\n    }\n    state.onError(onErrorParams{\n        streamErr: fmt.Errorf(\"active plan not found for plan ID %s on branch %s\", planId, branch),\n        storeDesc: true,\n    })\n}","handlingStrategy":"validation","validationCode":"if GetActivePlan(state.plan.Id, state.branch) == nil {\n    // skip chunk processing entirely; stream is already torn down\n    return\n}","typeGuard":"func (state *activeTellStreamState) hasActivePlan() bool {\n    return GetActivePlan(state.plan.Id, state.branch) != nil\n}","tryCatchPattern":"if GetActivePlan(planId, branch) == nil {\n    state.onActivePlanMissingError()\n    return\n}","preventionTips":["Guard every chunk handler with an active-plan existence check","Use a single owner for active-plan lifecycle (register/evict)","Log planId+branch on registration and eviction to spot mismatches","Avoid concurrent finish paths racing on the same active plan"],"tags":["in-memory-state","active-plan","stream","branch-mismatch"],"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"}