{"record":{"id":"7b62579628116021","repo":"plandex-ai/plandex","slug":"error-getting-version","errorCode":null,"errorMessage":"Error getting version","messagePattern":"Error getting version","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"app/server/routes/routes.go","lineNumber":65,"sourceCode":"\n\t\texecPath, err := os.Executable()\n\t\tif err != nil {\n\t\t\tlog.Fatal(\"Error getting current directory: \", err)\n\t\t}\n\t\tcurrentDir := filepath.Dir(execPath)\n\n\t\t// get version from version.txt\n\t\tvar path string\n\t\tif os.Getenv(\"IS_CLOUD\") != \"\" {\n\t\t\tpath = filepath.Join(currentDir, \"..\", \"version.txt\")\n\t\t} else {\n\t\t\tpath = filepath.Join(currentDir, \"version.txt\")\n\t\t}\n\n\t\tbytes, err := os.ReadFile(path)\n\n\t\tif err != nil {\n\t\t\thttp.Error(w, \"Error getting version\", http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\n\t\tfmt.Fprint(w, string(bytes))\n\t})\n}\n\nfunc AddApiRoutes(r *mux.Router) {\n\taddApiRoutes(r, \"\")\n}\n\nfunc AddApiRoutesWithPrefix(r *mux.Router, prefix string) {\n\taddApiRoutes(r, prefix)\n}\n\nfunc AddProxyableApiRoutes(r *mux.Router) {\n\taddProxyableApiRoutes(r, \"\")\n}","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/routes/routes.go#L47-L83","documentation":"The /version endpoint reads version.txt from the directory of the running server binary and returns its contents. If os.ReadFile fails (file missing or unreadable), the handler responds 500 'Error getting version'. This means the deployment is missing the version.txt file the build/packaging step should place next to (or one directory above, when IS_CLOUD is set) the binary.","triggerScenarios":"GET /version when version.txt does not exist at filepath.Dir(os.Executable()) (or its ../ parent when IS_CLOUD env var is non-empty), or the file exists but is not readable by the server process user.","commonSituations":"Running the server binary from source (go run) or a bare build that skipped the packaging step that copies version.txt; Docker image built without the version file; IS_CLOUD set in an environment where version.txt sits in the wrong directory; permission issues after extracting a release as another user.","solutions":["Check the server logs and confirm whether version.txt exists next to the binary: ls $(dirname $(which plandex-server))/version.txt (and ../version.txt if IS_CLOUD is set)","Rebuild or re-deploy using the project's packaging step so version.txt is copied beside the binary (e.g. re-run the release/Docker build)","If running in cloud mode, either unset IS_CLOUD or place version.txt in the parent directory of the binary","Fix file permissions so the server process user can read version.txt","As a defensive change, fall back to a build-time version constant (e.g. ldflags-injected version) when the file is missing"],"exampleFix":"// before\nbytes, err := os.ReadFile(path)\nif err != nil {\n\thttp.Error(w, \"Error getting version\", http.StatusInternalServerError)\n\treturn\n}\n// after\nbytes, err := os.ReadFile(path)\nif err != nil {\n\tlog.Printf(\"Error reading %s: %v\", path, err)\n\thttp.Error(w, \"Error getting version\", http.StatusInternalServerError)\n\treturn\n}","handlingStrategy":"fallback","validationCode":"path := filepath.Join(binDir, \"version.txt\") // or filepath.Join(binDir, \"..\", \"version.txt\") when IS_CLOUD is set\nif _, err := os.Stat(path); err != nil {\n\tlog.Printf(\"version.txt missing at %s; deployment packaging may be broken\", path)\n}","typeGuard":null,"tryCatchPattern":"resp, err := http.Get(serverURL + \"/version\")\nif err != nil {\n\treturn \"\", err\n}\ndefer resp.Body.Close()\nif resp.StatusCode != http.StatusOK {\n\treturn \"\", fmt.Errorf(\"/version returned status %d\", resp.StatusCode)\n}\nversion, err := io.ReadAll(resp.Body)\nif err != nil {\n\treturn \"\", err\n}\nreturn string(version), nil","preventionTips":["Ensure the build/packaging pipeline copies version.txt next to the server binary","When IS_CLOUD is set, verify version.txt is in the binary's parent directory","After deploying, smoke-test GET /version before routing traffic","Prefer embedding the version at build time (ldflags) so it cannot go missing at runtime"],"tags":["go","http","filesystem","deployment"],"backgroundTag":"file-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"}