{"record":{"id":"8f580573ebbf99bd","repo":"golang/go","slug":"malformed-prefix-q-escape-sequence-q-must-conta","errorCode":null,"errorMessage":"malformed prefix %q: escape sequence %q must contain two hex digits","messagePattern":"malformed prefix %q: escape sequence %q must contain two hex digits","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/internal/objabi/path.go","lineNumber":71,"sourceCode":"\t}\n\n\tp := make([]byte, 0, len(s))\n\tfor i := 0; i < len(s); {\n\t\tif s[i] != '%' {\n\t\t\tp = append(p, s[i])\n\t\t\ti++\n\t\t\tcontinue\n\t\t}\n\t\tif i+2 >= len(s) {\n\t\t\t// Not enough characters remaining to be a valid escape\n\t\t\t// sequence.\n\t\t\treturn \"\", fmt.Errorf(\"malformed prefix %q: escape sequence must contain two hex digits\", s)\n\t\t}\n\n\t\tb, err := strconv.ParseUint(s[i+1:i+3], 16, 8)\n\t\tif err != nil {\n\t\t\t// Not a valid escape sequence.\n\t\t\treturn \"\", fmt.Errorf(\"malformed prefix %q: escape sequence %q must contain two hex digits\", s, s[i:i+3])\n\t\t}\n\n\t\tp = append(p, byte(b))\n\t\ti += 3\n\t}\n\treturn string(p), nil\n}\n","sourceCodeStart":53,"sourceCodeEnd":79,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/internal/objabi/path.go#L53-L79","documentation":"`PrefixToPath` decodes `%xx` escape sequences in symbol table names. This error fires when the two characters following `%` are not valid hexadecimal digits (e.g., `%zz` or `%j3`). The code calls `strconv.ParseUint(s[i+1:i+3], 16, 8)` and on failure reports the specific invalid escape sequence.","triggerScenarios":"Calling `objabi.PrefixToPath(s)` where `s` contains `%` followed by characters that are not hex digits (0-9, a-f, A-F). For example, a symbol name containing a literal `%` that was not properly escaped by `PathToPrefix`.","commonSituations":"Hand-constructed or externally-generated symbol names containing unescaped `%`. Strings from a non-Go source that use `%` for a different purpose. Corrupted archive data. A tool that reads symbol names from DWARF or other debug sections without going through the proper encoding layer.","solutions":["Ensure all symbol names were encoded with `PathToPrefix` before being stored.","If the `%` is literal data, encode it properly: `PathToPrefix` turns `%` into `%25`.","Sanitize or reject externally-provided symbol names before decoding."],"exampleFix":"// before — raw string with literal % not encoded\ns := \"pkg%name\"\npath, err := objabi.PrefixToPath(s)  // fails: %n is not valid hex\n\n// after — encode first, then decode is lossless\nencoded := objabi.PathToPrefix(\"pkg%name\")  // → \"pkg%25name\"\npath, err := objabi.PrefixToPath(encoded)    // → \"pkg%name\"","handlingStrategy":"validation","validationCode":"// Validate that all %xx sequences contain valid hex digits\nfunc validateHexEscapes(s string) error {\n    for i := 0; i < len(s); i++ {\n        if s[i] == '%' {\n            if i+2 >= len(s) {\n                return fmt.Errorf(\"incomplete escape at %d\", i)\n            }\n            _, err := strconv.ParseUint(s[i+1:i+3], 16, 8)\n            if err != nil {\n                return fmt.Errorf(\"invalid hex escape %q at position %d\", s[i:i+3], i)\n            }\n            i += 2\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"func safePrefixToPath(s string) (string, error) {\n    path, err := objabi.PrefixToPath(s)\n    if err != nil && strings.Contains(err.Error(), \"must contain two hex digits\") {\n        return \"\", fmt.Errorf(\"corrupt symbol name %q: %w\", s, err)\n    }\n    return path, err\n}","preventionTips":["Encode all paths through PathToPrefix to guarantee valid %xx sequences.","If reading symbol names from external/debug sections, validate escape sequences before decoding.","Reject or quarantine symbol names containing literal % that were not produced by PathToPrefix."],"tags":["path-encoding","symbol-table","escape-sequence","objabi"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}