{"record":{"id":"32a1802124763a91","repo":"vxcontrol/pentagi","slug":"failed-to-get-absolute-path-w","errorCode":null,"errorMessage":"failed to get absolute path: %w","messagePattern":"failed to get absolute path: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/docker/client.go","lineNumber":167,"sourceCode":"\t\t\t\t\"to the configured external daemon at %q.\", cfg.DockerInsideHost)\n\t\tdefault:\n\t\t\tlogrus.Warn(\"DOCKER_INSIDE=true with neither DOCKER_SOCKET nor DOCKER_INSIDE_HOST set: \" +\n\t\t\t\t\"the host Docker socket will be autodetected and bind-mounted into every worker \" +\n\t\t\t\t\"container, so any process inside it gets control of the same daemon that runs \" +\n\t\t\t\t\"PentAGI. Set DOCKER_SOCKET or DOCKER_INSIDE_HOST explicitly, or front the socket \" +\n\t\t\t\t\"with a least-privilege proxy (e.g. Tecnativa/docker-socket-proxy), if that is not intended.\")\n\t\t}\n\t}\n\tnetName := cfg.DockerNetwork\n\tpublicIP := cfg.DockerPublicIP\n\tdefImage := strings.ToLower(cfg.DockerDefaultImage)\n\tif defImage == \"\" {\n\t\tdefImage = defaultImage\n\t}\n\n\tdataDir, err := filepath.Abs(cfg.DataDir)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get absolute path: %w\", err)\n\t}\n\n\tif err := os.MkdirAll(dataDir, 0755); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create tmp directory: %w\", err)\n\t}\n\n\thostDir := getHostDataDir(ctx, cli, dataDir, cfg.DockerWorkDir)\n\n\t// ensure network exists if configured\n\tif err := ensureDockerNetwork(ctx, cli, netName); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to ensure docker network %s: %w\", netName, err)\n\t}\n\n\tlogger := logrus.StandardLogger()\n\tlogger.WithFields(logrus.Fields{\n\t\t\"docker_name\":        info.Name,\n\t\t\"docker_arch\":        info.Architecture,\n\t\t\"docker_version\":     info.ServerVersion,","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/docker/client.go#L149-L185","documentation":"During NewDockerClient, the configured data directory (cfg.DataDir, e.g. DATA_DIR env) is converted to an absolute path with filepath.Abs before it is created and bind-mounted into worker containers. filepath.Abs essentially only fails when os.Getwd() fails, meaning the process's current working directory has been deleted or is unreadable. The error is wrapped as \"failed to get absolute path: %w\" and aborts client construction.","triggerScenarios":"filepath.Abs(cfg.DataDir) returns an error because os.Getwd() fails — the process was started in a directory that was subsequently removed or the cwd is inaccessible (permission, stale NFS mount). Also possible with a corrupt/unreadable cwd after container image changes.","commonSituations":"Starting the binary from a directory that was deleted while the process was running; launching via a wrapper script that cd's into a temp dir that vanished; running with a restricted cwd in a hardened sandbox; DATA_DIR passed as a relative path and cwd resolution failing.","solutions":["Restart the process from a valid working directory (cd /app && ./pentagi).","Set DATA_DIR to an absolute path so filepath.Abs never needs to resolve against cwd (it then only fails if Getwd fails, but avoid the dependency).","Check that the launch directory exists and is readable (ls -la $(pwd)).","If running under systemd/Docker, ensure WorkingDirectory points to an existing directory."],"exampleFix":"// before\ngolang DATA_DIR=data ./pentagi   # started in ./data's parent which was deleted\n// after\nexport DATA_DIR=/var/lib/pentagi/data   # absolute path\n/var/lib/pentagi/pentagi","handlingStrategy":"validation","validationCode":"if _, err := os.Stat(cfg.DataDir); err == nil {\n    // path exists; additionally ensure cwd is valid\n    if _, err := os.Getwd(); err != nil {\n        return fmt.Errorf(\"process cwd is invalid: %w\", err)\n    }\n}","typeGuard":null,"tryCatchPattern":"if _, err := NewDockerClient(ctx, db, cfg); err != nil {\n    var pe *fs.PathError\n    if errors.As(err, &pe) && strings.Contains(err.Error(), \"absolute path\") {\n        log.Fatalf(\"cwd invalid for DATA_DIR resolution: %v — restart from an existing directory\", err)\n    }\n    return err\n}","preventionTips":["Always configure DATA_DIR as an absolute path.","Launch the binary from a stable WorkingDirectory (systemd WorkingDirectory, Docker WORKDIR).","Avoid deleting directories a running process may be using as cwd.","Add a pre-start check that os.Getwd() succeeds."],"tags":["filesystem","path","startup"],"backgroundTag":"getwd-failed","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}