{"record":{"id":"cfc685b2da14827f","repo":"plandex-ai/plandex","slug":"error-building-whole-file-w","errorCode":null,"errorMessage":"error building whole file: %w","messagePattern":"error building whole file: %w","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"app/server/model/plan/build_race.go","lineNumber":106,"sourceCode":"\t\t\t\t}\n\t\t\t}()\n\t\t\tselect {\n\t\t\tcase <-buildCtx.Done():\n\t\t\t\tlog.Printf(\"buildRace - context already canceled, skipping whole file build\")\n\t\t\t\treturn\n\t\t\tdefault:\n\t\t\t}\n\n\t\t\tcontent, err := fileState.buildWholeFileFallback(buildCtx, proposedContent, desc, comments, sessionId)\n\n\t\t\tif err != nil {\n\t\t\t\tif errors.Is(err, context.Canceled) {\n\t\t\t\t\tlog.Printf(\"Context canceled during whole file build\")\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tlog.Printf(\"buildRace - whole file build failed: %v\", err)\n\t\t\t\tsendErr(fmt.Errorf(\"error building whole file: %w\", err))\n\t\t\t} else {\n\t\t\t\tlog.Printf(\"buildRace - whole file build succeeded\")\n\t\t\t\tsendRes(raceResult{content: content, valid: true})\n\t\t\t}\n\t\t}()\n\t}\n\n\tmaybeStartFastApply := func(onFail func()) {\n\t\tlog.Printf(\"buildRace - starting fast apply\")\n\t\tif !params.didCallFastApply {\n\t\t\tlog.Printf(\"buildRace - fast apply isn't defined, skipping\")\n\t\t\tsendErr(nil) // no error, just no fast apply\n\t\t\tonFail()\n\t\t\treturn\n\t\t}\n\n\t\tgo func() {\n\t\t\tdefer func() {","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/model/plan/build_race.go#L88-L124","documentation":"In buildRace (app/server/model/plan/build_race.go), the whole-file fallback build goroutine called buildWholeFileFallback and got a non-nil, non-cancellation error. This wrapper wraps the underlying error with %w so the root cause is preserved via errors.Is/Unwrap. It means the model-based full-file rewrite fallback could not produce content, not a syntax or validation problem.","triggerScenarios":"The <PlandexIncorrect/> marker was detected (or the initial replacement loop failed), triggering startWholeFileBuild; buildWholeFileFallback then returned an error (e.g. the LLM sub-request failed, streaming error, or internal error) that is not context.Canceled.","commonSituations":"LLM provider outages or rate limits during the fallback rewrite; context deadline errors other than context.Canceled (e.g. custom wrappers that don't match context.Canceled); nil session/config in the fallback path; network drops mid-stream.","solutions":["Inspect the wrapped cause with errors.Is/errors.As or read the log line 'buildRace - whole file build failed' immediately preceding it","Check LLM provider connectivity/API keys/rate limits used by buildWholeFileFallback","Verify the error type matches context.Canceled correctly (errors.Is, not ==) so cancellations are not misreported","Retry the whole plan/build operation once the transient provider issue clears"],"exampleFix":"// before\nsendErr(fmt.Errorf(\"error building whole file: %w\", err))\n// after\nif errors.Is(err, context.DeadlineExceeded) || isTransient(err) {\n\tlog.Printf(\"retrying whole file build after transient error: %v\", err)\n\tcontent, err = fileState.buildWholeFileFallback(buildCtx, proposedContent, desc, comments, sessionId)\n}\nif err != nil {\n\tsendErr(fmt.Errorf(\"error building whole file: %w\", err))\n\treturn\n}","handlingStrategy":"try-catch","validationCode":"// Go has no pre-call validation; guard the inputs\nif proposedContent == \"\" || sessionId == \"\" {\n\treturn fmt.Errorf(\"cannot start whole file build: missing proposedContent or sessionId\")\n}\nif err := buildCtx.Err(); err != nil {\n\treturn err // skip build if already canceled\n}","typeGuard":"func isCancellation(err error) bool {\n\treturn errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded)\n}","tryCatchPattern":"content, err := fileState.buildWholeFileFallback(buildCtx, proposedContent, desc, comments, sessionId)\nif err != nil {\n\tif isCancellation(err) {\n\t\treturn // user cancel: not a real failure\n\t}\n\tsendErr(fmt.Errorf(\"error building whole file: %w\", err))\n\treturn\n}","preventionTips":["Always check buildCtx.Err() before launching fallback builds","Use errors.Is (not ==) for context cancellation checks","Monitor LLM provider status and set sane retries/timeouts upstream","Log wrapped causes with %w and inspect them with errors.Is/As"],"tags":["go","llm","fallback","error-wrapping"],"backgroundTag":"llm-request-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"}