{"record":{"id":"3de90277a6c8ca3c","repo":"JuliusBrussee/caveman","slug":"cache-replay-output-directory-must-be-new-w","errorCode":null,"errorMessage":"cache-replay: output directory must be new: %w","messagePattern":"cache-replay: output directory must be new: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/cmd/cache-replay/main.go","lineNumber":440,"sourceCode":"\treturn result, nil\n}\n\nfunc validEnvironmentName(value string) bool {\n\tif value == \"\" || len(value) > 128 {\n\t\treturn false\n\t}\n\tfor index, char := range value {\n\t\tif char == '_' || char >= 'A' && char <= 'Z' || index > 0 && char >= '0' && char <= '9' {\n\t\t\tcontinue\n\t\t}\n\t\treturn false\n\t}\n\treturn true\n}\n\nfunc createEvidenceDirectory(path string) error {\n\tif err := os.Mkdir(path, 0o700); err != nil {\n\t\treturn fmt.Errorf(\"cache-replay: output directory must be new: %w\", err)\n\t}\n\tfor _, name := range []string{\"responses\", \"quality\", \"evidence\", \"observations\"} {\n\t\tif err := os.Mkdir(filepath.Join(path, name), 0o700); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc atomicWrite(path string, body []byte) error {\n\treturn atomicWriteStream(path, func(writer io.Writer) error {\n\t\t_, err := writer.Write(body)\n\t\treturn err\n\t})\n}\n\nfunc atomicWriteStream(path string, write func(io.Writer) error) error {\n\tdirectory := filepath.Dir(path)","sourceCodeStart":422,"sourceCodeEnd":458,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/cacheengine/cmd/cache-replay/main.go#L422-L458","documentation":"Raised by createEvidenceDirectory in cache-replay: os.Mkdir with O-exclude semantics failed, almost always because the output path already exists. Evidence directories must be new so a run's artifacts are never mixed with (or silently clobbered by) a previous run's.","triggerScenarios":"Thrown at cacheengine/cmd/cache-replay/main.go:440 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Choose a fresh, non-existent output directory path","Move or archive the existing directory, then re-run","Check the wrapped error for permission or filesystem causes if the path truly does not exist"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"766dce6b1394ebb56a3090748d5a0240a5aefb36","analyzedAt":"2026-08-18T03:14:35.516Z","contentChangedAt":"2026-08-18T03:14:35.516Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}