{"record":{"id":"6c7c85ab3676bebc","repo":"owasp-amass/amass","slug":"datasources-option-is-not-a-string","errorCode":null,"errorMessage":"datasources option is not a string","messagePattern":"datasources option is not a string","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/datasrcs.go","lineNumber":97,"sourceCode":"\t\t\tfor _, creds := range src.Creds {\n\t\t\t\treturn creds // Return the first set of credentials found\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc (c *Config) loadDataSourceSettings(cfg *Config) error {\n\t// Retrieve the datasources file path from the options\n\tpathInterface, ok := c.Options[\"datasources\"]\n\tif !ok {\n\t\t// \"datasources\" not found in options, so nothing to do here.\n\t\treturn nil\n\t}\n\n\tpath, ok := pathInterface.(string)\n\tif !ok {\n\t\treturn fmt.Errorf(\"datasources option is not a string\")\n\t}\n\t// Construct the absolute path by joining the current working directory and the relative path\n\tabsPath, err := c.AbsPathFromConfigDir(path)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get absolute path: %v\", err)\n\t}\n\t// Load the datasources YAML file\n\tdata, err := os.ReadFile(absPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error reading datasources file: %v\", err)\n\t}\n\t// Unmarshal the YAML data into a DataSourceConfig\n\tvar dsConfig DataSourceConfig\n\terr = yaml.Unmarshal(data, &dsConfig)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error unmarshalling datasources YAML: %v\", err)\n\t}\n","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/config/datasrcs.go#L79-L115","documentation":"loadDataSourceSettings reads the 'datasources' option from the config options map, which must be a string path to a data-sources file. If the value is present but not a string (number, bool, list, map), the load fails with 'datasources option is not a string'. This is an early type check before the path is resolved and loaded.","triggerScenarios":"A config with a non-string 'datasources' value, e.g. datasources: 123, datasources: true, or datasources: [a.yaml]. Triggered during LoadSettings when the key exists in options and the interface type assertion to string fails.","commonSituations":"Hand-edited YAML where an unquoted filename looks numeric (datasources: 2024.yaml becomes an int); tooling that generated the config with the wrong type; misunderstanding that datasources takes a file path, not an inline list.","solutions":["Quote the value so YAML parses it as a string: datasources: \"datasources.yaml\".","Confirm the option expects a path to a datasources file, not an inline structure.","Validate the config with a YAML parser and inspect the datasources value's type.","If the value is generated programmatically, stringify it before writing the config."],"exampleFix":"// before (config.yaml)\ndatasources: 2024\n// after\ndatasources: \"2024.yaml\"","handlingStrategy":"validation","validationCode":"raw, _ := os.ReadFile(cfgPath)\nvar doc map[string]any\n_ = yaml.Unmarshal(raw, &doc)\nif v, ok := doc[\"datasources\"]; ok {\n    if _, ok := v.(string); !ok {\n        return fmt.Errorf(\"datasources must be a string path, got %T\", v)\n    }\n}","typeGuard":"func isString(v any) bool {\n    _, ok := v.(string)\n    return ok\n}","tryCatchPattern":"if err := cfg.LoadSettings(path); err != nil {\n    if strings.Contains(err.Error(), \"datasources option is not a string\") {\n        // quote the value or correct the type in the config\n    }\n    return err\n}","preventionTips":["Quote the datasources path in YAML so it parses as a string","Validate config types in CI with a schema check","Stringify programmatically generated values before writing configs","Document that datasources expects a file path, not inline data"],"tags":["config","yaml","type-mismatch","validation"],"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"}