{"record":{"id":"fade6ab60553048a","repo":"projectdiscovery/nuclei","slug":"could-not-parse-hexdump","errorCode":null,"errorMessage":"could not parse hexdump","messagePattern":"could not parse hexdump","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/protocols/common/helpers/responsehighlighter/hexdump.go","lineNumber":49,"sourceCode":"func (hexDump HighlightableHexDump) len() int {\n\treturn len(hexDump.index)\n}\n\nfunc (hexDump HighlightableHexDump) String() string {\n\tvar result string\n\tfor i := 0; i < hexDump.len(); i++ {\n\t\tresult += hexDump.index[i] + hexDump.hex[i] + \"|\" + hexDump.ascii[i] + \"|\\n\"\n\t}\n\treturn result\n}\n\nfunc toHighLightedHexDump(hexDump, snippetToHighlight string) (HighlightableHexDump, error) {\n\thexDumpRowValues := hexDumpParsePattern.FindAllStringSubmatch(hexDump, -1)\n\tif hexDumpRowValues == nil || len(hexDumpRowValues) != strings.Count(hexDump, \"\\n\") {\n\t\tmessage := \"could not parse hexdump\"\n\t\tgologger.Warning().Msg(message)\n\n\t\treturn HighlightableHexDump{}, errors.New(message)\n\t}\n\n\tresult := NewHighlightableHexDump(len(hexDumpRowValues))\n\tfor _, currentHexDumpRowValues := range hexDumpRowValues {\n\t\tresult.index = append(result.index, currentHexDumpRowValues[1])\n\t\tresult.hex = append(result.hex, currentHexDumpRowValues[2])\n\t\tresult.ascii = append(result.ascii, currentHexDumpRowValues[3])\n\t}\n\treturn result.highlight(snippetToHighlight), nil\n}\n\nfunc (hexDump HighlightableHexDump) highlight(snippetToColor string) HighlightableHexDump {\n\treturn highlightAsciiSection(highlightHexSection(hexDump, snippetToColor), snippetToColor)\n}\n\nfunc highlightHexSection(hexDump HighlightableHexDump, snippetToColor string) HighlightableHexDump {\n\tvar snippetHexCharactersMatchPattern string\n\tfor _, char := range snippetToColor {","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/projectdiscovery/nuclei/blob/265b3a3dec374741614e342f813c10f8b38d2bb7/pkg/protocols/common/helpers/responsehighlighter/hexdump.go#L31-L67","documentation":"Raised by toHighLightedHexDump in the terminal response highlighter (hexdump.go:49). It re-parses an already-rendered hexdump with a row regex; if no rows match, or the matched row count differs from the number of newlines in the input, the dump is considered malformed and the function logs a gologger warning and returns this error. It is a presentation-layer failure: the match data itself is fine, only the colored hexdump view could not be built.","triggerScenarios":"Calling ResponseHighlighter on binary response content whose generated hexdump rows do not align with the parse pattern (e.g. rows with unusual offsets or truncated last lines), so FindAllStringSubmatch returns nil or a mismatched count.","commonSituations":"Viewing binary protocol responses in a terminal; truncated responses that cut a hexdump row in half; downstream code that mutates the dump string between render and highlight.","solutions":["Treat the error as non-fatal: log it and fall back to printing the raw or plain-formatted response","Ensure the hexdump passed in is the unmodified output of the package's own dumper","Compare row count vs newline count yourself before highlighting if you build dumps manually"],"exampleFix":"// before\nhd, err := responsehighlighter.toHighLightedHexDump(dump, marker)\nif err != nil { return err }\n// after\nhd, err := responsehighlighter.toHighLightedHexDump(dump, marker)\nif err != nil { hd = plainFallback(dump) } // degrade, do not fail","handlingStrategy":"fallback","validationCode":"rows := hexDumpParsePattern.FindAllStringSubmatch(dump, -1)\nif rows == nil || len(rows) != strings.Count(dump, \"\\n\") { /* use plain rendering now */ }","typeGuard":"func isHexdumpParseFailure(err error) bool { return err != nil && err.Error() == \"could not parse hexdump\" }","tryCatchPattern":"hd, err := toHighLightedHexDump(dump, marker)\nif err != nil { // presentation-only failure\n    gologger.Debug().Err(err).Msg(\"hexdump highlight skipped\")\n    return dump // plain output\n}","preventionTips":["Never mutate the rendered dump before highlighting","Treat highlight failures as cosmetic; keep the scan path independent of display code"],"tags":["hexdump","output-formatting","binary","terminal"],"backgroundTag":null,"analyzedSha":"265b3a3dec374741614e342f813c10f8b38d2bb7","analyzedAt":"2026-08-15T20:05:51.855Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}