{"record":{"id":"eabbd80214128ef5","repo":"owasp-amass/amass","slug":"failed-to-load-the-configuration-file-v","errorCode":null,"errorMessage":"failed to load the configuration file: %v","messagePattern":"failed to load the configuration file: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/oam_i2y/ini.go","lineNumber":118,"sourceCode":"// Database contains values required for connecting with graph databases.\ntype Database struct {\n\tSystem   string\n\tPrimary  bool   `ini:\"primary\"`\n\tURL      string `ini:\"url\"`\n\tUsername string `ini:\"username\"`\n\tPassword string `ini:\"password\"`\n\tDBName   string `ini:\"database\"`\n\tOptions  string `ini:\"options\"`\n}\n\n// LoadSettings parses settings from an .ini file and assigns them to the Config.\nfunc (c *Config) LoadSettings(path string) error {\n\tcfg, err := ini.LoadSources(ini.LoadOptions{\n\t\tInsensitive:  true,\n\t\tAllowShadows: true,\n\t}, path)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to load the configuration file: %v\", err)\n\t}\n\t// Get the easy ones out of the way using mapping\n\tif err = cfg.MapTo(c); err != nil {\n\t\treturn fmt.Errorf(\"error mapping configuration settings to internal values: %v\", err)\n\t}\n\t// Attempt to load a special mode of operation specified by the user\n\tif cfg.Section(ini.DefaultSection).HasKey(\"mode\") {\n\t\tmode := cfg.Section(ini.DefaultSection).Key(\"mode\").String()\n\n\t\tswitch mode {\n\t\tcase \"passive\":\n\t\t\tc.Passive = true\n\t\tcase \"active\":\n\t\t\tc.Active = true\n\t\t}\n\t}\n\n\tloads := []func(cfg *ini.File) error{","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/cmd/oam_i2y/ini.go#L100-L136","documentation":"LoadSettings parses an INI configuration file with go-ini's LoadSources (case-insensitive keys, shadow values allowed). If the file cannot be read or parsed as INI, the underlying error is wrapped with this message.","triggerScenarios":"Passing a path to a nonexistent file, a directory, a file with permission errors, or content that is not valid INI syntax (unclosed sections, garbage bytes) to Config.LoadSettings.","commonSituations":"Wrong path passed to oam_i2y (-i flag typo); config file with YAML/JSON content instead of INI; file deleted or renamed after deployment; encoding issues (UTF-16 exports from Windows tools).","solutions":["Verify the file exists and is readable at the given path (os.Stat, ls -l).","Ensure the file is valid INI syntax — [section] headers and key=value pairs, correct encoding (UTF-8/ASCII).","Read the wrapped %v error for the precise cause (no such file vs permission denied vs parse error) and fix accordingly."],"exampleFix":"// before\nerr := cfg.LoadSettings(\"/etc/amass/config.ini.bak2\")\n// after\npath := \"/etc/amass/config.ini\"\nif _, err := os.Stat(path); err != nil {\n    log.Fatalf(\"config not found: %v\", err)\n}\nerr := cfg.LoadSettings(path)","handlingStrategy":"try-catch","validationCode":"if fi, err := os.Stat(path); err != nil {\n    return fmt.Errorf(\"config file missing: %w\", err)\n} else if fi.IsDir() {\n    return fmt.Errorf(\"config path is a directory: %s\", path)\n}","typeGuard":null,"tryCatchPattern":"if err := cfg.LoadSettings(path); err != nil {\n    if strings.Contains(err.Error(), \"failed to load the configuration file\") {\n        // surface wrapped cause, prompt user for correct -i path\n        return fmt.Errorf(\"check --config path %s: %w\", path, err)\n    }\n}","preventionTips":["Validate the config path exists before invoking the tool.","Keep configs in INI format, UTF-8 encoded.","Version-control the config so accidental deletions are recoverable."],"tags":["config","ini","go"],"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-14T05:17:10.506Z"}