{"record":{"id":"5186493e9ccb5d49","repo":"caddyserver/caddy","slug":"dir-mode-w","errorCode":null,"errorMessage":"dir_mode: %w","messagePattern":"dir_mode: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/logging/filewriter.go","lineNumber":215,"sourceCode":"\tdirPath := filepath.Dir(fw.Filename)\n\tswitch strings.ToLower(strings.TrimSpace(fw.DirMode)) {\n\tcase \"\", \"0\":\n\t\t// Preserve current behavior: locked-down directories by default.\n\t\tif err := os.MkdirAll(dirPath, 0o700); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\tcase \"inherit\":\n\t\tif err := mkdirAllInherit(dirPath); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\tcase \"from_file\":\n\t\tif err := mkdirAllFromFile(dirPath, os.FileMode(fw.Mode)); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\tdefault:\n\t\tdm, err := parseFileMode(fw.DirMode)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"dir_mode: %w\", err)\n\t\t}\n\t\tif err := os.MkdirAll(dirPath, dm); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// create/open the file\n\tfile, err := os.OpenFile(fw.Filename, os.O_WRONLY|os.O_APPEND|os.O_CREATE, modeIfCreating)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tinfo, err := file.Stat()\n\tif roll {\n\t\tfile.Close() // timberjack will reopen it on its own\n\t}\n\n\t// Ensure already existing files have the right mode, since OpenFile will not set the mode in such case.\n\tif configuredMode := os.FileMode(fw.Mode); configuredMode != 0 {","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/modules/logging/filewriter.go#L197-L233","documentation":"Error \"dir_mode: %w\" thrown in caddyserver/caddy.","triggerScenarios":"Thrown at modules/logging/filewriter.go:215 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a valid octal permission mode for dir_mode, e.g. '0755'."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}