{"record":{"id":"25be201651017925","repo":"plandex-ai/plandex","slug":"error-building-plan-v","errorCode":null,"errorMessage":"error building plan: %v","messagePattern":"error building plan: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/plan_exec/build.go","lineNumber":66,"sourceCode":"\t\tlog.Println(\"Build canceled\")\n\t\treturn false, nil\n\t}\n\n\tapiErr = api.Client.BuildPlan(params.CurrentPlanId, params.CurrentBranch, shared.BuildPlanRequest{\n\t\tConnectStream: !buildBg,\n\t\tProjectPaths:  paths.ActivePaths,\n\t\tAuthVars:      params.AuthVars,\n\t}, stream.OnStreamPlan)\n\n\tterm.StopSpinner()\n\n\tif apiErr != nil {\n\t\tif apiErr.Msg == shared.NoBuildsErr {\n\t\t\tfmt.Println(\"🤷‍♂️ This plan has no pending changes to build\")\n\t\t\treturn false, nil\n\t\t}\n\n\t\treturn false, fmt.Errorf(\"error building plan: %v\", apiErr.Msg)\n\t}\n\n\tif !buildBg {\n\t\tch := make(chan error)\n\n\t\tgo func() {\n\t\t\terr := streamtui.StartStreamUI(\"\", true, !flags.AutoApply)\n\n\t\t\tif err != nil {\n\t\t\t\tch <- fmt.Errorf(\"error starting stream UI: %v\", err)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tch <- nil\n\t\t}()\n\n\t\t// Wait for the stream to finish\n\t\terr := <-ch","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/plan_exec/build.go#L48-L84","documentation":"Build wraps a non-nil API error message returned by the server when the plan build request fails. It is not the 'no pending changes' case (NoBuildsErr is handled separately) — it is a genuine build failure reported by the backend, surfaced verbatim via apiErr.Msg.","triggerScenarios":"The build API call returns an error whose Msg is not shared.NoBuildsErr: server-side build failure, invalid plan state, authentication/session errors, or internal server error.","commonSituations":"Plan in a corrupt/invalid state after a crashed build; server rejected the build because of a conflicting concurrent build; expired auth producing an API error message.","solutions":["Read the wrapped apiErr.Msg for the server-side cause","Re-run the build; transient server errors often resolve on retry","Re-authenticate (login) if the message indicates auth issues","If the plan state is corrupt, reset or rebuild the plan from a prior commit"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// check session/auth state before building\nif _, err := api.Client.PlanContexts(...); err != nil {\n    term.OutputErrorAndExit(\"re-authenticate before building: %v\", err)\n}","typeGuard":"func isNoBuildsErr(err error) bool {\n    var apiErr *shared.ApiErr\n    return errors.As(err, &apiErr) && apiErr.Msg == shared.NoBuildsErr\n}","tryCatchPattern":"ok, err := Build(params)\nif err != nil {\n    if strings.Contains(err.Error(), \"error building plan\") {\n        // inspect server message; retry transient failures, re-auth on 401\n    }\n    return err\n}","preventionTips":["Avoid running concurrent builds on the same plan","Re-authenticate before long sessions","Check server status if builds fail repeatedly","Keep the plan state consistent (don't kill builds mid-flight)"],"tags":["api","build","server-error"],"backgroundTag":"plan-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"}