{"record":{"id":"fd131aa75466c8b5","repo":"owasp-amass/amass","slug":"environment-variable-s-is-not-set","errorCode":null,"errorMessage":"environment variable %s is not set","messagePattern":"environment variable (.+?) is not set","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/graphdb.go","lineNumber":72,"sourceCode":"\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}\n\n// LoadDatabaseEnvSettings initializes the DB structure with the Environment variables.\nfunc (c *Config) LoadDatabaseEnvSettings() error {\n\tdbURI := \"\"\n\tdb := &Database{\n\t\tPrimary: true,\n\t\tSystem:  \"postgres\",\n\t}\n\n\tvar u string\n\tif uenv, set := os.LookupEnv(amassUser); set {\n\t\tu = uenv\n\t} else {\n\t\treturn fmt.Errorf(\"environment variable %s is not set\", amassUser)\n\t}\n\tdb.Username = u\n\th := \"localhost\"\n\tif dbEnv, set := os.LookupEnv(assetDB); set {\n\t\th = dbEnv\n\t}\n\tdb.Host = h\n\tport := \"5432\"\n\tif pEnv, set := os.LookupEnv(assetPort); set {\n\t\tport = pEnv\n\t}\n\tdb.Port = port\n\tn := \"assetdb\"\n\tif nEnv, set := os.LookupEnv(assetDBName); set {\n\t\tn = nEnv\n\t}\n\tdb.DBName = n\n\tif p, set := os.LookupEnv(amassPass); set {","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/config/graphdb.go#L54-L90","documentation":"LoadDatabaseEnvSettings in config/graphdb.go requires that the AMASS_USER (amassUser) environment variable is set before configuring the graph database credentials. If os.LookupEnv finds the variable unset, it returns this error immediately instead of building a Database entry. It is the library's way of refusing to run with anonymous/empty DB credentials.","triggerScenarios":"Calling LoadSettings or loadDatabaseSettings (directly or in tests via TestLoadDatabaseEnvSettings) when the amassUser environment variable is not present in the process environment.","commonSituations":"Running amass from cron/systemd/CI where the interactive shell environment (with the exported variable) is not inherited; forgetting to export the variable before running; a typo in the variable name.","solutions":["Set the environment variable (export it in the shell or service unit) before running: export $(amassUser value).","Check the exact variable name with `printenv | grep -i amass` to rule out typos.","If running under systemd/docker, add the variable to the unit's Environment= or env_file / -e flag.","As a last resort inspect config/graphdb.go:72 to confirm the expected variable name in your version."],"exampleFix":"// before\n$ ./amass enum\n// error: environment variable AMASS_USER is not set\n// after\n$ export AMASS_USER=dbuser\n$ ./amass enum","handlingStrategy":"validation","validationCode":"if os.Getenv(\"AMASS_USER\") == \"\" {\n    return errors.New(\"AMASS_USER must be set before loading settings\")\n}","typeGuard":null,"tryCatchPattern":"if err := config.LoadDatabaseEnvSettings(); err != nil {\n    var envErr *config.EnvVarError\n    if errors.As(err, &envErr) { /* prompt for env var */ }\n}","preventionTips":["Set required DB env vars in shell profiles or service env files","Fail fast at startup with an env-var preflight check","Document required env vars in deployment configs"],"tags":["environment","configuration","database"],"backgroundTag":"missing-env-var","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"}