{"record":{"id":"5d7a7a0fe927cb3e","repo":"plandex-ai/plandex","slug":"v-from-err-error","errorCode":null,"errorMessage":"%v (from err.Error())","messagePattern":"(.+?) \\(from err\\.Error\\(\\)\\)","errorType":"exception","errorClass":null,"httpStatus":500,"severity":"error","filePath":"app/server/model/plan/build_finish.go","lineNumber":301,"sourceCode":"\tactivePlan := GetActivePlan(planId, branch)\n\n\tif activePlan == nil {\n\t\tlog.Println(\"onBuildFileError - Active plan not found\")\n\t\treturn\n\t}\n\n\tlog.Printf(\"Error for file %s: %v\\n\", filePath, err)\n\n\tactiveBuild.Success = false\n\tactiveBuild.Error = err\n\n\tgo notify.NotifyErr(notify.SeverityError, fmt.Errorf(\"error for file %s: %v\", filePath, err))\n\n\tactivePlan.StreamDoneCh <- &shared.ApiError{\n\t\tType:   shared.ApiErrorTypeOther,\n\t\tStatus: http.StatusInternalServerError,\n\t\tMsg:    err.Error(),\n\t}\n\n\tif err != nil {\n\t\tlog.Printf(\"Error storing plan error result: %v\\n\", err)\n\t}\n\n\tbuild.Error = err.Error()\n\n\terr = db.SetBuildError(build)\n\tif err != nil {\n\t\tlog.Printf(\"Error setting build error: %v\\n\", err)\n\t}\n}\n\nfunc (fileState *activeBuildStreamFileState) buildNextInQueue() bool {\n\tfilePath := fileState.filePath\n\tactivePlan := GetActivePlan(fileState.plan.Id, fileState.branch)\n\tif activePlan == nil {\n\t\tlog.Println(\"onFinishBuildFile - Active plan not found\")","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/model/plan/build_finish.go#L283-L319","documentation":"onBuildFileError is the generic per-file build error handler: whenever a file build (execPlanBuild, buildFile, buildStructuredEdits, buildWholeFileFallback) fails for any reason, the raw err.Error() text is sent to the client as a 500 ApiError via StreamDoneCh and recorded on build.Error via db.SetBuildError. The message shown is the underlying error, so its content varies — LLM stream failures, parse failures, context cancellation, etc.","triggerScenarios":"Any failure inside a file build path that calls onBuildFileError: the model stream errored or was canceled, the LLM response failed validation/parsing into file edits, context length exceeded, or an internal step returned an error that bubbles to this handler.","commonSituations":"LLM provider outages or rate limits during a build; malformed model output that can't be applied as edits; plan canceled while a file was streaming; context window too small for the target file; misconfigured API keys causing provider errors.","solutions":["Read the actual Msg sent to the client (it's err.Error()) and the server log line \"Error for file <path>: ...\" to identify the underlying failure","If it's a provider/stream error, check API keys, rate limits, and provider status, then retry the build","If the response failed to parse/apply, retry the operation or switch to a stronger model / whole-file fallback","If context length is implicated, add fewer files to context or reduce the target file size","The build's Error field is persisted via db.SetBuildError — inspect the build record for the retained message"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// the client receives the 500 ApiError on the stream; handle and inspect Msg\nresp, err := client.GetPlanBuildStream(...)\nif apiErr, ok := err.(*shared.ApiError); ok {\n\tlog.Printf(\"build failed for plan: %s (type=%s status=%d)\", apiErr.Msg, apiErr.Type, apiErr.Status)\n\tif strings.Contains(apiErr.Msg, \"context length\") {\n\t\t// trim plan context and retry\n\t} else if isProviderError(apiErr.Msg) {\n\t\t// check keys/rate limits and retry\n\t}\n}","preventionTips":["Keep LLM API keys valid and monitor provider rate limits/status before large builds","Keep target files and plan context within the configured model's context window","Retry failed builds — many underlying causes (provider blips, truncation) are transient","Inspect the persisted build.Error field (SetBuildError) when triaging failures after the fact"],"tags":["plandex","server","llm","plan-build","error-propagation"],"backgroundTag":"plan-file-build-failed","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"}