{"record":{"id":"bfd035736a807516","repo":"owasp-amass/amass","slug":"failed-to-obtain-the-output-directory","errorCode":null,"errorMessage":"failed to obtain the output directory","messagePattern":"failed to obtain the output directory","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/sessions/session.go","lineNumber":275,"sourceCode":"\t\t}\n\t}\n\t// Check if a valid database connection string was generated.\n\tif s.dsn == \"\" || s.dbtype == \"\" {\n\t\treturn errors.New(\"no primary database specified in the configuration\")\n\t}\n\t// Initialize the database store\n\tstore, err := assetdb.New(s.dbtype, s.dsn)\n\tif err != nil {\n\t\treturn errors.New(\"failed to initialize database store: \" + err.Error())\n\t}\n\ts.db = store\n\treturn nil\n}\n\nfunc (s *Session) createTemporaryDir() (string, error) {\n\toutdir := config.OutputDirectory()\n\tif outdir == \"\" {\n\t\treturn \"\", errors.New(\"failed to obtain the output directory\")\n\t}\n\n\tdir, err := os.MkdirTemp(outdir, \"session-\"+s.ID().String())\n\tif err != nil {\n\t\treturn \"\", errors.New(\"failed to create the temp dir\")\n\t}\n\n\treturn dir, nil\n}\n\nfunc (s *Session) createSessionPipelines(reg et.Registry) error {\n\ts.pipelines = make(et.SessionPipelines, len(oam.AssetList))\n\n\tfor _, atype := range oam.AssetList {\n\t\tp, err := reg.BuildAssetPipeline(s.Ctx(), atype)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}","sourceCodeStart":257,"sourceCodeEnd":293,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/engine/sessions/session.go#L257-L293","documentation":"createTemporaryDir calls config.OutputDirectory() to find where session temp directories should live; if it returns an empty string, the library cannot determine a base directory and throws this error. It is thrown before any filesystem operation, purely as a guard against an unconfigured/empty output path.","triggerScenarios":"CreateSession -> createTemporaryDir when the output directory config value is unset, empty after trimming, or not initialized in the config package before session creation.","commonSituations":"User omitted the output-dir setting in the config file; config loaded from the wrong file; initialization order issue where session creation runs before config loading; flag/env override evaluated to empty string.","solutions":["Set the output directory in the configuration (file setting, flag, or env var) before creating a session","Verify config.Load/Init was actually called and succeeded prior to CreateSession","Check for typos or empty values in the output-directory config key","Log config.OutputDirectory() at startup to confirm it resolves to a real path"],"exampleFix":"// before\n{ \"server\": { \"listen\": \":4433\" } }\n// after\n{ \"server\": { \"listen\": \":4433\" }, \"output\": { \"directory\": \"/var/lib/myapp/output\" } }","handlingStrategy":"validation","validationCode":"outdir := config.OutputDirectory()\nif outdir == \"\" {\n    return errors.New(\"output directory must be configured before session creation\")\n}\nif fi, err := os.Stat(outdir); err != nil || !fi.IsDir() {\n    return fmt.Errorf(\"output directory %q is missing or not a directory\", outdir)\n}","typeGuard":null,"tryCatchPattern":"if err := session.CreateSession(cfg); err != nil {\n    if strings.Contains(err.Error(), \"failed to obtain the output directory\") {\n        log.Fatal(\"output directory is not configured; set output.directory in config\")\n    }\n    return err\n}","preventionTips":["Set output.directory explicitly in every environment's config","Call config.Init/Load before any session creation and fail fast on empty values","Add a startup assertion that logs the resolved output directory","Use env-var defaults (e.g. OUTPUT_DIR) so the value is never silently empty"],"tags":["configuration","filesystem","session"],"backgroundTag":"missing-config-value","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"}