{"record":{"id":"a7a23f259ed73cc8","repo":"projectdiscovery/katana","slug":"result-is-empty","errorCode":null,"errorMessage":"result is empty","messagePattern":"result is empty","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/output/output.go","lineNumber":263,"sourceCode":"\n\tswitch {\n\tcase w.outputTemplate != nil:\n\t\toutputKind = \"template\"\n\t\tdata, err = w.formatTemplate(result)\n\tcase w.json:\n\t\toutputKind = \"JSON\"\n\t\tdata, err = w.formatJSON(result)\n\tdefault:\n\t\toutputKind = \"screen\"\n\t\tdata, err = w.formatScreen(result)\n\t}\n\n\tif err != nil {\n\t\treturn errkit.Wrap(err, fmt.Sprintf(\"output: could not format %s output\", outputKind))\n\t}\n\n\tif len(data) == 0 {\n\t\treturn errors.New(\"result is empty\")\n\t}\n\n\t// Increment result count only for valid results that produce output\n\tatomic.AddInt64(&w.resultCount, 1)\n\n\tw.outputMutex.Lock()\n\tdefer w.outputMutex.Unlock()\n\n\tgologger.Silent().Msgf(\"%s\", string(data))\n\tif w.outputFile != nil {\n\t\tif !w.json {\n\t\t\tdata = decolorizerRegex.ReplaceAll(data, []byte(\"\"))\n\t\t}\n\t\tif err := w.outputFile.Write(data); err != nil {\n\t\t\treturn errkit.Wrap(err, \"output: could not write to output\")\n\t\t}\n\t}\n","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/projectdiscovery/katana/blob/e3e742739c3746f085943ce918fb4e2b8daf6fe6/pkg/output/output.go#L245-L281","documentation":"StandardWriter.Write returns this when the formatted output (data) produced for the result is zero bytes — after formatting via template, JSON, or screen mode, nothing was rendered. The writer refuses to emit empty output so blank lines and empty JSON objects are not written to files or screen.","triggerScenarios":"Calling Write(result) where formatTemplate/formatJSON/formatScreen returns success but an empty byte slice — typically an output template that resolves to an empty string for this result, or formatting fields that are all empty (e.g. after -omit-raw/-omit-body stripped everything).","commonSituations":"Custom output template whose placeholders evaluate to empty for certain results (missing fields, filtered attributes); using -omit-body/-omit-raw so screen output collapses to nothing; JSON output of a result stripped of all fields.","solutions":["Check the output template: ensure at least one placeholder resolves non-empty for every result (e.g. include {{URL}}).","Verify -omit-raw/-omit-body options are not stripping the only fields your template/screen format uses.","Log result fields before Write to confirm which fields are empty for the failing result.","Skip such results in the caller, or fall back to a default template that always renders the URL."],"exampleFix":"// before\noutputTemplate = \"{{Body}}\" // empty when -omit-body is set\n// after\noutputTemplate = \"{{URL}} {{Body}}\" // URL always non-empty\n","handlingStrategy":"validation","validationCode":"func producesOutput(r *output.Result, tpl string, omitRaw, omitBody bool) bool {\n    if tpl != \"\" {\n        rendered := renderTemplate(tpl, r, omitRaw, omitBody)\n        return strings.TrimSpace(rendered) != \"\"\n    }\n    return true\n}","typeGuard":null,"tryCatchPattern":"if err := writer.Write(result); err != nil {\n    if err.Error() == \"result is empty\" {\n        log.Warnf(\"rendered output empty for %s; check template/omit flags\", result.Request.URL)\n        return nil\n    }\n    return err\n}","preventionTips":["Include a always-non-empty field (e.g. URL) in output templates","Check interactions between -omit-raw/-omit-body and your template fields","Smoke-test templates with real results before long runs"],"tags":["output","formatting","template","go"],"backgroundTag":"empty-output-produced","analyzedSha":"e3e742739c3746f085943ce918fb4e2b8daf6fe6","analyzedAt":"2026-09-03T14:55:13.248Z","contentChangedAt":"2026-09-03T14:55:13.248Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}