{"record":{"id":"b2ac3f17c9f7c2e5","repo":"projectdiscovery/subfinder","slug":"empty-filename","errorCode":null,"errorMessage":"empty filename","messagePattern":"empty filename","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/runner/outputter.go","lineNumber":50,"sourceCode":"\tSource              string `json:\"source\"`\n\tWildcardCertificate bool   `json:\"wildcard_certificate,omitempty\"`\n}\n\ntype jsonSourcesResult struct {\n\tHost                string   `json:\"host\"`\n\tInput               string   `json:\"input\"`\n\tSources             []string `json:\"sources\"`\n\tWildcardCertificate bool     `json:\"wildcard_certificate,omitempty\"`\n}\n\n// NewOutputWriter creates a new OutputWriter\nfunc NewOutputWriter(json bool) *OutputWriter {\n\treturn &OutputWriter{JSON: json}\n}\n\nfunc (o *OutputWriter) createFile(filename string, appendToFile bool) (*os.File, error) {\n\tif filename == \"\" {\n\t\treturn nil, errors.New(\"empty filename\")\n\t}\n\n\tdir := filepath.Dir(filename)\n\n\tif dir != \"\" {\n\t\tif _, err := os.Stat(dir); os.IsNotExist(err) {\n\t\t\terr := os.MkdirAll(dir, os.ModePerm)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t}\n\n\tvar file *os.File\n\tvar err error\n\tif appendToFile {\n\t\tfile, err = os.OpenFile(filename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)\n\t} else {","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/projectdiscovery/subfinder/blob/7a0b91f0fac01b62c65328bd771a3560ae611d6a/pkg/runner/outputter.go#L32-L68","documentation":"Guard in OutputWriter.createFile that fires when the output filename argument is the empty string, i.e. no -o/-oO output path was actually supplied to the file-writing path. It is a sentinel validation error raised before os.Create/os.OpenFile is attempted.","triggerScenarios":"Thrown at pkg/runner/outputter.go:50 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check that the -o or -oN/-oJ/-oH output flag carries a non-empty path before invoking the outputter","Default the filename to a sane value (e.g. derived from the domain) when the caller passes an empty string","Treat an empty filename as 'write to stdout' instead of routing it into createFile"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a0b91f0fac01b62c65328bd771a3560ae611d6a","analyzedAt":"2026-09-06T23:52:02.109Z","contentChangedAt":"2026-09-06T23:52:02.109Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}