{"record":{"id":"4091e01866b6498c","repo":"plandex-ai/plandex","slug":"active-plan-not-found-for-plan-id-s-and-branch-s-4091e0","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_validate_and_fix.go","lineNumber":468,"sourceCode":"\t// log.Printf(\"Final content:\\n\\n%s\", final)\n\n\treturn buildValidateResult{valid: false, updated: final, problem: problem}, nil\n}\n\nfunc (fileState *activeBuildStreamFileState) validationRetryOrError(buildCtx context.Context, validateParams buildValidateParams, err error) (buildValidateResult, error) {\n\tlog.Printf(\"Handling validation error for file: %s\", fileState.filePath)\n\tif fileState.validationNumRetry < MaxBuildErrorRetries {\n\t\tfileState.validationNumRetry++\n\n\t\tlog.Printf(\"Retrying validation (attempt %d/%d) due to error: %v\",\n\t\t\tfileState.validationNumRetry, MaxBuildErrorRetries, err)\n\n\t\tactivePlan := GetActivePlan(fileState.plan.Id, fileState.branch)\n\n\t\tif activePlan == nil {\n\t\t\tlog.Printf(\"Active plan not found for plan ID %s and branch %s\",\n\t\t\t\tfileState.plan.Id, fileState.branch)\n\t\t\treturn buildValidateResult{}, fmt.Errorf(\"active plan not found for plan ID %s and branch %s\",\n\t\t\t\tfileState.plan.Id, fileState.branch)\n\t\t}\n\n\t\tselect {\n\t\tcase <-buildCtx.Done():\n\t\t\tlog.Printf(\"Context canceled during retry wait\")\n\t\t\treturn buildValidateResult{}, context.Canceled\n\t\tcase <-time.After(time.Duration(fileState.validationNumRetry*fileState.validationNumRetry)*200*time.Millisecond + time.Duration(rand.Intn(500))*time.Millisecond):\n\t\t\tlog.Printf(\"Retry wait completed, attempting validation again\")\n\t\t\tbreak\n\t\t}\n\n\t\treturn fileState.buildValidate(buildCtx, validateParams)\n\t} else {\n\t\tlog.Printf(\"Max retries (%d) exceeded, returning error\", MaxBuildErrorRetries)\n\t\treturn buildValidateResult{}, err\n\t}\n}","sourceCodeStart":450,"sourceCodeEnd":486,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/model/plan/build_validate_and_fix.go#L450-L486","documentation":"During build validate-and-fix retry handling, the active plan lookup by plan ID + branch returns no plan, so validation retries cannot proceed. Means the plan was deleted/concurrently changed while a build was in flight.","triggerScenarios":"buildValidate reaches the retry/error path while the plan identified by fileState.plan.Id and fileState.branch is no longer active (removed or never registered).","commonSituations":"Plan was deleted/finished concurrently, wrong branch name, or the plan was never activated before the build ran.","solutions":["Ensure the plan is created and activated before starting build validation","Verify fileState.plan.Id and fileState.branch match a registered active plan","Check for code that deactivates/removes plans concurrently with the build"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if GetActivePlan(planId, branch) == nil {\n    return fmt.Errorf(\"plan %s not active on branch %s; activate before building\", planId, branch)\n}","typeGuard":"func planIsActive(planId, branch string) bool { return GetActivePlan(planId, branch) != nil }","tryCatchPattern":"res, err := buildValidate(ctx, ...)\nif err != nil && strings.Contains(err.Error(), \"active plan not found\") {\n    // re-activate or re-create the plan, then retry once\n}","preventionTips":["Register/activate plans before starting builds","Keep plan lifecycle (activation/cleanup) synchronized with build jobs","Verify branch names match exactly when looking up plans"],"tags":["go","state","plan-lookup","concurrency"],"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"}