{"record":{"id":"0aff0a7c02022608","repo":"owasp-amass/amass","slug":"error-mapping-configuration-settings-to-internal-v","errorCode":null,"errorMessage":"error mapping configuration settings to internal values: %v","messagePattern":"error mapping configuration settings to internal values: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/oam_i2y/ini.go","lineNumber":122,"sourceCode":"\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{\n\t\tc.loadResolverSettings,\n\t\tc.loadScopeSettings,\n\t\tc.loadAlterationSettings,\n\t\tc.loadBruteForceSettings,","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/cmd/oam_i2y/ini.go#L104-L140","documentation":"After loading the INI file, LoadSettings uses go-ini's cfg.MapTo(c) to map settings onto the Config struct via field tags. If any value cannot be converted to the target field type (e.g. a non-integer string for an int field), MapTo fails and this error wraps the cause.","triggerScenarios":"An INI key whose value's type doesn't match the Config struct field (e.g. \"port = abc\" for an int field, \"sensitive = maybe\" for a bool), or a key mapped to an unsupported field type.","commonSituations":"Hand-edited config files with typos in numeric/boolean values; copy-pasting values with units (\"30s\", \"8080/tcp\"); locale-formatted numbers; schema drift after upgrading where keys changed meaning.","solutions":["Read the wrapped %v error — go-ini names the offending key/value — and correct that key's value type in the INI file.","Make every value match the Config struct field types: integers unquoted, booleans true/false, no units or whitespace.","Compare against a known-good example config shipped with the tool and fix diffs."],"exampleFix":"// before (config.ini)\nport = 8080/tcp\n// after\nport = 8080","handlingStrategy":"validation","validationCode":"// lint config values against expected types before LoadSettings\nfor _, kv := range numericKeys {\n    if _, err := strconv.Atoi(values[kv]); err != nil {\n        return fmt.Errorf(\"key %s must be an integer, got %q\", kv, values[kv])\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := cfg.LoadSettings(path); err != nil {\n    if strings.Contains(err.Error(), \"error mapping configuration settings\") {\n        // wrapped go-ini error names the bad key/value; fix that line\n        return err\n    }\n}","preventionTips":["Hand-edit numeric/boolean values without units, spaces, or locale formatting.","Validate the config with the tool's example/template file after edits.","Add a CI check that loads the config with LoadSettings before release."],"tags":["config","ini","type-mismatch","go"],"backgroundTag":"config-type-mismatch","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"}