{"record":{"id":"bebe71078a50bf46","repo":"plandex-ai/plandex","slug":"error-loading-build-file-v","errorCode":null,"errorMessage":"error loading build file: %v","messagePattern":"error loading build file: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/server/model/plan/build_exec.go","lineNumber":196,"sourceCode":"\t}\n\n\tfileState := &activeBuildStreamFileState{\n\t\tactiveBuildStreamState: buildState,\n\t\tfilePath:               filePath,\n\t\tactiveBuild:            activeBuild,\n\t\tbuilderRun: hooks.DidFinishBuilderRunParams{\n\t\t\tStartedAt: time.Now(),\n\t\t\tPlanId:    activePlan.Id,\n\t\t\tFilePath:  filePath,\n\t\t\tFileExt:   filepath.Ext(filePath),\n\t\t},\n\t}\n\n\tlog.Printf(\"execPlanBuild - %s - calling fileState.loadBuildFile()\\n\", filePath)\n\terr := fileState.loadBuildFile(activeBuild)\n\tif err != nil {\n\t\tlog.Printf(\"Error loading build file: %v\\n\", err)\n\t\tfileState.onBuildFileError(fmt.Errorf(\"error loading build file: %v\", err))\n\t\treturn\n\t}\n\n\tfileState.resolvePreBuildState()\n\n\t// unless it's a file operation, stream initial status to client\n\tif !activeBuild.IsFileOperation() && !fileState.isNewFile {\n\t\tlog.Printf(\"execPlanBuild - %s - streaming initial build info\\n\", filePath)\n\t\t// spew.Dump(activeBuild)\n\t\tbuildInfo := &shared.BuildInfo{\n\t\t\tPath:      filePath,\n\t\t\tNumTokens: 0,\n\t\t\tFinished:  false,\n\t\t}\n\t\tactivePlan.Stream(shared.StreamMessage{\n\t\t\tType:      shared.StreamMessageBuildInfo,\n\t\t\tBuildInfo: buildInfo,\n\t\t})","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/model/plan/build_exec.go#L178-L214","documentation":"This error is raised in execPlanBuild when fileState.loadBuildFile(activeBuild) returns an error while executing the build for a single plan file. loadBuildFile reads the file from the repo and computes the pre-build context part; any failure reading/parsing that state is wrapped as 'error loading build file: %v' and passed to onBuildFileError, which marks the build file as failed and aborts that file's build (the rest of the build continues). The underlying err is the real cause — inspect the server log line printed just before this error.","triggerScenarios":"queueBuild -> execPlanBuild for a file path that cannot be loaded: the file does not exist on the plan branch (path stale or renamed), the path is a directory/invalid, file-system permission or I/O failure while reading it, or an internal error inside loadBuildFile (e.g. corrupted plan file state for that path).","commonSituations":"Plan context references a file that was deleted or renamed outside the app; building on the wrong branch where the file doesn't exist; read-permission problems on the mounted repo volume; a prior build left inconsistent plan file state in the DB.","solutions":["Check the preceding log line 'Error loading build file: ...' to get the wrapped underlying err and fix that root cause first","Verify the file exists on the plan's branch (git ls-tree / open it in the workspace) and that the build path matches the actual path","Check file permissions/ownership so the server process can read the file","If plan file state is inconsistent, re-sync the plan branch or restart the build from a fresh conversation state","Retry the build after fixing the file; the error is per-file so other files still build"],"exampleFix":"// before: build references a path that was renamed\n// build.Path = \"old/path.go\"\n// after: correct the build path to the existing file\n// build.Path = \"new/path.go\"\nerr := fileState.loadBuildFile(activeBuild)\nif err != nil {\n    fileState.onBuildFileError(fmt.Errorf(\"error loading build file: %v\", err))\n    return\n}","handlingStrategy":"validation","validationCode":"func validateBuildPath(branch, path string) error {\n    if path == \"\" || filepath.IsAbs(path) {\n        return fmt.Errorf(\"invalid build path: %q\", path)\n    }\n    if _, err := os.Stat(filepath.Join(repoRoot, path)); err != nil {\n        return fmt.Errorf(\"build file missing on branch %s: %w\", branch, err)\n    }\n    return nil\n}","typeGuard":"func fileExists(root, path string) bool {\n    fi, err := os.Stat(filepath.Join(root, path))\n    return err == nil && !fi.IsDir()\n}","tryCatchPattern":"err := fileState.loadBuildFile(activeBuild)\nif err != nil {\n    log.Printf(\"error loading build file: %v\", err)\n    fileState.onBuildFileError(err) // surface wrapped cause to client\n    return\n}","preventionTips":["Validate that every build path exists on the target branch before queueing the build","Keep file paths in plan context in sync with workspace renames/deletes","Ensure the server process has read access to the repo volume","Log the wrapped cause err, not just the wrapper message"],"tags":["go","build","filesystem","file-io"],"backgroundTag":"build-file-load-failed","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}