{"record":{"id":"6e17cc64c4ba7326","repo":"caddyserver/caddy","slug":"path-component-s-exists-and-is-not-a-directory","errorCode":null,"errorMessage":"path component %s exists and is not a directory","messagePattern":"path component (.+?) exists and is not a directory","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/logging/filewriter.go","lineNumber":328,"sourceCode":"}\n\n// mkdirAllInherit creates missing dirs using the nearest existing parent's\n// permissions, normalized with r→x.\nfunc mkdirAllInherit(dir string) error {\n\tif fi, err := os.Stat(dir); err == nil && fi.IsDir() {\n\t\treturn nil\n\t}\n\tcur := dir\n\tvar parent string\n\tfor {\n\t\tnext := filepath.Dir(cur)\n\t\tif next == cur {\n\t\t\tparent = next\n\t\t\tbreak\n\t\t}\n\t\tif fi, err := os.Stat(next); err == nil {\n\t\t\tif !fi.IsDir() {\n\t\t\t\treturn fmt.Errorf(\"path component %s exists and is not a directory\", next)\n\t\t\t}\n\t\t\tparent = next\n\t\t\tbreak\n\t\t}\n\t\tcur = next\n\t}\n\tperm := os.FileMode(0o700)\n\tif fi, err := os.Stat(parent); err == nil && fi.IsDir() {\n\t\tperm = fi.Mode().Perm()\n\t}\n\tperm = normalizeDirPerm(perm)\n\treturn os.MkdirAll(dir, perm)\n}\n\n// mkdirAllFromFile creates missing dirs using the file's mode (with r→x) so\n// 0644 → 0755, 0600 → 0700, etc.\nfunc mkdirAllFromFile(dir string, fileMode os.FileMode) error {\n\tif fi, err := os.Stat(dir); err == nil && fi.IsDir() {","sourceCodeStart":310,"sourceCodeEnd":346,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/modules/logging/filewriter.go#L310-L346","documentation":"Error \"path component %s exists and is not a directory\" thrown in caddyserver/caddy.","triggerScenarios":"Thrown at modules/logging/filewriter.go:328 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Choose a different log file path, or remove/rename the conflicting non-directory file at that path."],"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-15T17:31:12.345Z"}