{"record":{"id":"4ae91da8018954d6","repo":"hashicorp/nomad","slug":"failed-to-resolve-requested-path-w","errorCode":null,"errorMessage":"failed to resolve requested path: %w","messagePattern":"failed to resolve requested path: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"client/allocdir/alloc_dir.go","lineNumber":423,"sourceCode":"\t\t}\n\t}\n\treturn files, err\n}\n\n// sanitizePath checks that the path does not escape the alloc directory,\n// does not read into the secrets or private directories and returns an absolute\n// path of the provided path.\nfunc (a *AllocDir) sanitizePath(path string) (string, error) {\n\t// In some non linux systmes, directories like /var and /tmp resolve to\n\t// /private/var and /private/tmp.\n\tresolvedAllocDir, err := filepath.EvalSymlinks(a.AllocDir)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to resolve alloc directory: %w\", err)\n\t}\n\n\trequestedPath, err := filepath.Abs(filepath.Join(resolvedAllocDir, path))\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to resolve requested path: %w\", err)\n\t}\n\n\tif err := escapingfs.ChildEscapesParentDir(resolvedAllocDir, requestedPath); err != nil {\n\t\treturn \"\", fmt.Errorf(\"path escapes the alloc directory\")\n\t}\n\n\ta.mu.RLock()\n\tdefer a.mu.RUnlock()\n\n\t// Check it does not access the secrets or private directories\n\tfor _, taskDir := range a.TaskDirs {\n\t\trps := strings.ReplaceAll(requestedPath, \"/Secrets\", \"/secrets\")\n\t\tif err := escapingfs.ChildEscapesParentDir(taskDir.SecretsDir, rps); err == nil {\n\t\t\treturn \"\", fmt.Errorf(\"Reading secret file prohibited: %s\", path)\n\t\t}\n\n\t\trpp := strings.ReplaceAll(requestedPath, \"/Private\", \"/private\")\n\t\tif err := escapingfs.ChildEscapesParentDir(taskDir.PrivateDir, rpp); err == nil {","sourceCodeStart":405,"sourceCodeEnd":441,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/allocdir/alloc_dir.go#L405-L441","documentation":"After resolving the alloc dir, sanitizePath() joins the requested path and calls filepath.Abs. If computing the absolute path fails, this wrapped error is returned from all path-consuming APIs (List, Stat, ReadAt, etc.).","triggerScenarios":"Calling any file API with a path such that filepath.Abs(filepath.Join(resolvedAllocDir, path)) errors — rare in practice, e.g. extremely long paths exceeding system limits (ENAMETOOLONG) or platform-specific invalid characters on Windows.","commonSituations":"Client submits a task file path with pathological length; Windows client with illegal path characters; deep directory nesting pushing past MAX_PATH.","solutions":["Shorten the requested path or reduce alloc dir nesting depth","Remove invalid characters from the requested path for the target OS","Retry once the underlying cause (path length/charset) is corrected"],"exampleFix":"// before\nallocDir.ReadAt(\"task/\" + strings.Repeat(\"d/\", 200) + \"f\", 0)\n// after\nrel := \"task/short-name\"\nallocDir.ReadAt(rel, 0)","handlingStrategy":"validation","validationCode":"if len(path) > 4096 {\n    return fmt.Errorf(\"requested path too long: %d\", len(path))\n}","typeGuard":null,"tryCatchPattern":"f, err := allocDir.ReadAt(path, 0)\nif err != nil && strings.Contains(err.Error(), \"failed to resolve requested path\") {\n    return fmt.Errorf(\"unusable path (too long/invalid for OS?): %q\", path)\n}","preventionTips":["Keep alloc-relative paths short; avoid pathological nesting","Strip OS-invalid characters before requesting paths","Sanitize user-supplied path inputs before API calls"],"tags":["filesystem","path-resolution","filepath"],"backgroundTag":"path-resolution-failed","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}