{"record":{"id":"7d29fd2f37f40049","repo":"owasp-amass/amass","slug":"failed-to-get-absolute-path-v-7d29fd","errorCode":null,"errorMessage":"failed to get absolute path: %v","messagePattern":"failed to get absolute path: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/resolvers.go","lineNumber":221,"sourceCode":"\n\t}\n\n\t// Deduplicate the list of resolvers and assign to c.Resolvers.\n\tresolverIPs := stringset.Deduplicate(resolversList)\n\n\tif len(resolverIPs) == 0 {\n\t\treturn errors.New(\"no valid resolvers were found\")\n\t}\n\n\tc.Resolvers = resolverIPs\n\n\treturn nil\n}\n\nfunc (c *Config) loadResolversFromFile(path string) ([]string, error) {\n\tabsPath, err := filepath.Abs(path)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get absolute path: %v\", err)\n\t}\n\n\tdata, err := os.ReadFile(absPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to open resolvers file: %w\", err)\n\t}\n\n\t// Split the file data by newlines to get the IP addresses.\n\tlines := strings.Split(string(data), \"\\n\")\n\n\tvar resolvers []string\n\tfor _, line := range lines {\n\t\tline = strings.TrimSpace(line)\n\t\t// Skip empty lines.\n\t\tif line == \"\" {\n\t\t\tcontinue\n\t\t}\n","sourceCodeStart":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/config/resolvers.go#L203-L239","documentation":"loadResolversFromFile first converts the given path to an absolute path with filepath.Abs. Although filepath.Abs rarely fails (it can fail when os.Getwd fails, e.g. the working directory was deleted), any such error is wrapped as 'failed to get absolute path'.","triggerScenarios":"Calling loadResolversFromFile (directly in tests via TestLoadResolversFromFile, or via loadResolverSettings) while the process's current working directory is invalid/deleted, making filepath.Abs unable to resolve a relative path.","commonSituations":"Running the tool from a directory that was removed or renamed while the process lives; exotic environments where os.Getwd fails; passing relative paths from a container whose workdir vanished.","solutions":["Run the tool from a valid existing working directory (cd / before invoking).","Pass an absolute path for the resolver file so filepath.Abs does not need the working directory.","Restart the process from a valid directory if the workdir was deleted underneath it."],"exampleFix":"// before\n$ cd /tmp/scratch && rm -rf /tmp/scratch & amass ...\n// after\n$ cd ~ && amass ...  # resolver file given as absolute path","handlingStrategy":"try-catch","validationCode":"if _, err := os.Getwd(); err != nil {\n    return errors.New(\"current working directory is invalid; cd to a real directory\")\n}","typeGuard":null,"tryCatchPattern":"resolvers, err := loadResolversFromFile(path)\nif err != nil {\n    var pe *fs.PathError\n    if errors.As(err, &pe) {\n        return nil, fmt.Errorf(\"resolver file %s: %w\", pe.Path, pe)\n    }\n    return nil, err\n}","preventionTips":["Always pass absolute paths to file-loading APIs","Avoid running long-lived processes from temporary directories that may be removed","Verify os.Getwd works at startup when using relative paths"],"tags":["filesystem","path","environment"],"backgroundTag":"file-not-found","analyzedSha":"79299dce87b0085db0f2f4ef3e9c52cccb49f514","analyzedAt":"2026-09-06T08:22:48.198Z","contentChangedAt":"2026-09-06T08:22:48.198Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}