{"record":{"id":"c4a2831d62ab171e","repo":"vxcontrol/pentagi","slug":"failed-to-resolve-data-directory-w","errorCode":null,"errorMessage":"failed to resolve data directory: %w","messagePattern":"failed to resolve data directory: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/tools/tools.go","lineNumber":736,"sourceCode":"\n\treturn writeErr\n}\n\nfunc convertSyncEntriesToTarEntries(entries []fileSyncEntry) []flowfiles.TarEntry {\n\ttarEntries := make([]flowfiles.TarEntry, 0, len(entries))\n\tfor _, entry := range entries {\n\t\ttarEntries = append(tarEntries, flowfiles.TarEntry{\n\t\t\tLocalPath: entry.localPath,\n\t\t\tTarPath:   entry.tarPath,\n\t\t})\n\t}\n\treturn tarEntries\n}\n\nfunc (fte *flowToolsExecutor) cachedUploadsDir() (string, error) {\n\tdataDir, err := filepath.Abs(fte.cfg.DataDir)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to resolve data directory: %w\", err)\n\t}\n\n\treturn flowfiles.FlowUploadsDir(dataDir, uint64(fte.flowID)), nil\n}\n\nfunc (fte *flowToolsExecutor) cachedResourcesDir() (string, error) {\n\tdataDir, err := filepath.Abs(fte.cfg.DataDir)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to resolve data directory: %w\", err)\n\t}\n\n\treturn flowfiles.FlowResourcesDir(dataDir, uint64(fte.flowID)), nil\n}\n\nfunc (fte *flowToolsExecutor) Release(ctx context.Context) error {\n\tif fte.store != nil {\n\t\t// Do NOT close the store when it is backed by the shared pgxpool — the pool\n\t\t// outlives individual flows and is shared by all executors. Only close when","sourceCodeStart":718,"sourceCodeEnd":754,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/tools/tools.go#L718-L754","documentation":"This error wraps filepath.Abs failing while resolving the configured data directory (fte.cfg.DataDir) to an absolute path for the flow's cached uploads directory. filepath.Abs only fails when it cannot determine the current working directory (os.Getwd error), e.g. the working directory was deleted. The wrapped error comes from os.Getwd.","triggerScenarios":"filepath.Abs(fte.cfg.DataDir) returns an error because os.Getwd fails: the process's current working directory was removed, or getwd is unavailable (restricted environment).","commonSituations":"Backend binary started in a directory that was later deleted (e.g. temp dir cleanup while running under systemd/tmux/CI); DataDir configured as a relative path making it depend on CWD; containers where WORKDIR was removed at runtime.","solutions":["Restart the backend process from a valid existing working directory","Configure DataDir as an absolute path (e.g. /data) so filepath.Abs is independent of CWD — set DATA_DIR in .env/docker-compose","Check the process still has a valid CWD: ls -l /proc/<pid>/cwd","Fix deployment unit files (systemd WorkingDirectory, Docker WORKDIR) so the start directory exists and persists"],"exampleFix":"// before\ndataDir, err := filepath.Abs(fte.cfg.DataDir)\nif err != nil {\n\treturn \"\", fmt.Errorf(\"failed to resolve data directory: %w\", err)\n}\n// after (config side) — make DataDir absolute at load time\nif !filepath.IsAbs(cfg.DataDir) {\n\treturn \"\", fmt.Errorf(\"DATA_DIR must be an absolute path, got %q\", cfg.DataDir)\n}","handlingStrategy":"validation","validationCode":"// at config load time\nif cfg.DataDir == \"\" {\n\treturn errors.New(\"DATA_DIR is not set\")\n}\nif !filepath.IsAbs(cfg.DataDir) {\n\tabs, err := filepath.Abs(cfg.DataDir) // fails only if CWD is gone\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot resolve relative DATA_DIR %q: %w\", cfg.DataDir, err)\n\t}\n\tcfg.DataDir = abs\n}\nif err := os.MkdirAll(cfg.DataDir, 0o755); err != nil {\n\treturn err\n}","typeGuard":null,"tryCatchPattern":"dir, err := fte.cachedUploadsDir()\nif err != nil {\n\t// fall back to an absolute default location instead of failing the flow\n\tlog.Warn().Err(err).Msg(\"data dir resolve failed; using fallback\")\n\tdir = \"/data/flow-uploads\"\n}","preventionTips":["Always configure DATA_DIR as an absolute path","Start the process from a stable, persistent working directory (systemd WorkingDirectory, Docker WORKDIR)","Do not delete the directory the binary was launched from while it runs","MkdirAll the data dir at startup and fail fast if unavailable"],"tags":["filesystem","config","paths"],"backgroundTag":"working-directory-unavailable","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}