owasp-amass/amass · error

failed to obtain the output directory

Error message

failed to obtain the output directory

What it means

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.

Source

Thrown at engine/sessions/session.go:275

		}
	}
	// Check if a valid database connection string was generated.
	if s.dsn == "" || s.dbtype == "" {
		return errors.New("no primary database specified in the configuration")
	}
	// Initialize the database store
	store, err := assetdb.New(s.dbtype, s.dsn)
	if err != nil {
		return errors.New("failed to initialize database store: " + err.Error())
	}
	s.db = store
	return nil
}

func (s *Session) createTemporaryDir() (string, error) {
	outdir := config.OutputDirectory()
	if outdir == "" {
		return "", errors.New("failed to obtain the output directory")
	}

	dir, err := os.MkdirTemp(outdir, "session-"+s.ID().String())
	if err != nil {
		return "", errors.New("failed to create the temp dir")
	}

	return dir, nil
}

func (s *Session) createSessionPipelines(reg et.Registry) error {
	s.pipelines = make(et.SessionPipelines, len(oam.AssetList))

	for _, atype := range oam.AssetList {
		p, err := reg.BuildAssetPipeline(s.Ctx(), atype)
		if err != nil {
			return err
		}

View on GitHub (pinned to 79299dce87)

Solutions

  1. Set the output directory in the configuration (file setting, flag, or env var) before creating a session
  2. Verify config.Load/Init was actually called and succeeded prior to CreateSession
  3. Check for typos or empty values in the output-directory config key
  4. Log config.OutputDirectory() at startup to confirm it resolves to a real path

Example fix

// before
{ "server": { "listen": ":4433" } }
// after
{ "server": { "listen": ":4433" }, "output": { "directory": "/var/lib/myapp/output" } }
Defensive patterns

Strategy: validation

Validate before calling

outdir := config.OutputDirectory()
if outdir == "" {
    return errors.New("output directory must be configured before session creation")
}
if fi, err := os.Stat(outdir); err != nil || !fi.IsDir() {
    return fmt.Errorf("output directory %q is missing or not a directory", outdir)
}

Try / catch

if err := session.CreateSession(cfg); err != nil {
    if strings.Contains(err.Error(), "failed to obtain the output directory") {
        log.Fatal("output directory is not configured; set output.directory in config")
    }
    return err
}

Prevention

When it happens

Trigger: CreateSession -> createTemporaryDir when the output directory config value is unset, empty after trimming, or not initialized in the config package before session creation.

Common situations: 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.

Understand the failure class

Background: "missing required config value" errors: why libraries refuse to start when a configuration key is empty, unset, or blank — this error's family across 48 libraries.

Related errors


AI-assisted analysis of owasp-amass/amass@79299dce87 (2026-09-06). Data as JSON: /api/errors/bfd035736a807516. Report an issue: GitHub.