{"record":{"id":"db32abfde883c150","repo":"owasp-amass/amass","slug":"failed-to-create-the-temp-dir","errorCode":null,"errorMessage":"failed to create the temp dir","messagePattern":"failed to create the temp dir","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/sessions/session.go","lineNumber":280,"sourceCode":"\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}\n\t\ts.pipelines[atype] = p\n\t}\n\n\treturn nil\n}","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/engine/sessions/session.go#L262-L298","documentation":"After the output directory resolves, createTemporaryDir calls os.MkdirTemp(outdir, \"session-\"+id) to create the per-session directory; if that syscall fails, this error replaces the detailed OS error. It indicates the output directory exists as a path value but a temp directory could not be created inside it.","triggerScenarios":"CreateSession -> createTemporaryDir when os.MkdirTemp fails: the output directory does not exist, is not writable, is actually a file, or the filesystem is full/read-only.","commonSituations":"Output directory configured but never created (app does not MkdirAll); permission denied after service user change; disk full on the volume; SELinux/container read-only mount on the output path; session ID producing an unusable prefix.","solutions":["Pre-create the output directory with correct permissions (os.MkdirAll(outdir, 0o755)) before session creation","Check directory ownership/writability for the user running the process","Confirm the output path is a directory, not a file, and on a writable (not read-only) filesystem","Check disk space and inode availability on the volume","Temporarily log the underlying os.MkdirTemp error to see the precise errno"],"exampleFix":"// before\noutdir := config.OutputDirectory()\nif _, err := os.Stat(outdir); err != nil { log.Fatal(err) }\n// after\noutdir := config.OutputDirectory()\nif err := os.MkdirAll(outdir, 0o755); err != nil {\n    log.Fatalf(\"cannot create output dir %s: %v\", outdir, err)\n}","handlingStrategy":"validation","validationCode":"outdir := config.OutputDirectory()\nif err := os.MkdirAll(outdir, 0o755); err != nil {\n    return fmt.Errorf(\"cannot prepare output dir %s: %w\", outdir, err)\n}\nif fi, err := os.Stat(outdir); err != nil || !fi.IsDir() || unix.Access(outdir, unix.W_OK) != nil {\n    return fmt.Errorf(\"output dir %s is not writable\", outdir)\n}","typeGuard":null,"tryCatchPattern":"if err := session.CreateSession(cfg); err != nil {\n    if strings.Contains(err.Error(), \"failed to create the temp dir\") {\n        log.Fatalf(\"cannot create temp dir under %s: check permissions, disk space, and mount flags\", config.OutputDirectory())\n    }\n    return err\n}","preventionTips":["Create the output directory at service startup with os.MkdirAll and correct ownership","Run the process as a user with write access to the output path","Monitor disk space on the volume holding the output directory","Avoid read-only container mounts on the output path"],"tags":["filesystem","permissions","session"],"backgroundTag":"mkdir-permission-denied","analyzedSha":"79299dce87b0085db0f2f4ef3e9c52cccb49f514","analyzedAt":"2026-09-06T08:22:48.198Z","contentChangedAt":"2026-09-06T08:22:48.198Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}