{"record":{"id":"36e8aabfeb6d9c8e","repo":"owasp-amass/amass","slug":"failed-to-load-the-main-configuration-file-v","errorCode":null,"errorMessage":"failed to load the main configuration file: %v","messagePattern":"failed to load the main configuration file: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"config/config.go","lineNumber":273,"sourceCode":"}\n\n// LoadSettings parses settings from an .yaml file and assigns them to the Config.\nfunc (c *Config) LoadSettings(path string) error {\n\t// Determine and store the absolute path of the config file\n\tabsolutePath, err := filepath.Abs(path)\n\tif err != nil {\n\t\t_ = c.LoadDatabaseEnvSettings()\n\t\t_ = c.LoadEngineEnvSettings()\n\t\treturn fmt.Errorf(\"failed to get absolute path of the configuration file: %v\", err)\n\t}\n\tc.Filepath = absolutePath\n\n\t// Open the configuration file\n\tdata, err := os.ReadFile(c.Filepath)\n\tif err != nil {\n\t\t_ = c.LoadDatabaseEnvSettings()\n\t\t_ = c.LoadEngineEnvSettings()\n\t\treturn fmt.Errorf(\"failed to load the main configuration file: %v\", err)\n\t}\n\n\terr = yaml.Unmarshal(data, c)\n\tif err != nil {\n\t\t_ = c.LoadDatabaseEnvSettings()\n\t\t_ = c.LoadEngineEnvSettings()\n\t\treturn fmt.Errorf(\"error mapping configuration settings to internal values: %v\", err)\n\t}\n\n\tif err := c.loadSeedandScopeSettings(); err != nil {\n\t\treturn err\n\t}\n\n\tloads := []func(cfg *Config) error{\n\t\tc.loadAlterationSettings,\n\t\tc.loadBruteForceSettings,\n\t\tc.loadDatabaseSettings,\n\t\tc.loadDataSourceSettings,","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/config/config.go#L255-L291","documentation":"LoadSettings reads the configuration file at c.Filepath with os.ReadFile; if the read fails it loads database/engine env settings as a fallback and returns 'failed to load the main configuration file'. This means the config path resolved but the file could not be opened and read (missing, permission denied, or it is a directory).","triggerScenarios":"Calling LoadSettings with a path to a nonexistent file, a file the process cannot read, or a directory. Also triggered when the file was deleted between the earlier filepath.Abs and the read.","commonSituations":"Wrong --config path typo; running the tool as a user without read access to /etc/... config; mounting the config into a container at the wrong path; relative path intended for a different CWD.","solutions":["Verify the path exists: `ls -l <path>`; correct typos in the config path argument.","Fix permissions: `chmod +r <config>` or run as a user with access.","If the path is relative, confirm the process's working directory, or pass an absolute path.","As a stopgap, set the relevant DATABASE/ENGINE env vars since LoadSettings still applies env settings before failing."],"exampleFix":"// before\nerr := cfg.LoadSettings(\"./confg.yaml\") // typo\n// after\nerr := cfg.LoadSettings(\"./config.yaml\")","handlingStrategy":"validation","validationCode":"func assertReadable(path string) error {\n    info, err := os.Stat(path)\n    if err != nil {\n        return fmt.Errorf(\"config not accessible: %w\", err)\n    }\n    if info.IsDir() {\n        return fmt.Errorf(\"%s is a directory\", path)\n    }\n    f, err := os.Open(path)\n    if err != nil {\n        return fmt.Errorf(\"config unreadable: %w\", err)\n    }\n    return f.Close()\n}","typeGuard":null,"tryCatchPattern":"if err := cfg.LoadSettings(path); err != nil {\n    if strings.Contains(err.Error(), \"failed to load the main configuration file\") {\n        // check the path exists and is readable; env-based DB/engine settings were still applied\n    }\n    return err\n}","preventionTips":["Verify the config path with `ls` before launching","Use absolute paths for the main config","Ensure the runtime user has read access (esp. /etc configs, containers)","Check mount points in containers match the configured path"],"tags":["config","file-read","permissions","file-not-found"],"backgroundTag":"config-file-not-found","analyzedSha":"79299dce87b0085db0f2f4ef3e9c52cccb49f514","analyzedAt":"2026-09-06T08:22:48.198Z","contentChangedAt":"2026-09-06T08:22:48.198Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}