fix(frontend): preserve \u00XX escapes in Avro JSON viewer#2425
fix(frontend): preserve \u00XX escapes in Avro JSON viewer#2425
Conversation
Avro's JSON encoding represents bytes/fixed as ISO-8859-1 code points (\u00XX for anything above 0x7F). Running the normalized payload through JSON.parse then JSON.stringify for display launders those escapes into literal Unicode glyphs (e.g. Û -> U+00DB -> "Û"), so "Copy Value" placed UTF-8 bytes on the clipboard instead of the original byte. Scoped to payload.encoding === 'avro' only. KowlJsonView now re-escapes code points in 0x80-0xFF back to \u00XX before display when called from an avro payload view, which is lossless for both Avro bytes fields (recovers the exact byte) and legitimate Latin-1 strings (valid JSON escape for the same Unicode character). Non-avro encodings (proto, json, text, etc.) are unchanged. Fixes #2421. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@claude review |
|
Claude finished @weeco's task in 1m 55s —— View job Code Review
The fix is correct and well-scoped. Root cause analysis is accurate and the implementation addresses it cleanly. A few observations:
|
Summary
bytes/fixedfields.\u00XX), but the frontend runs the payload throughJSON.parsethenJSON.stringifyfor display.JSON.stringifydoes not re-escape non-ASCII, so a byte like0xDBrenders as the literal glyphÛand "Copy Value" places UTF-8 bytes on the clipboard instead of the original byte.KowlJsonViewgains an optionalescapeLatin1prop that re-escapes code points in0x80-0xFFback to\u00XXbefore display.PayloadComponentsets it only whenpayload.encoding === 'avro', so non-avro payloads are unchanged.Test plan
bytesfield (e.g. DebeziumVariableScaleDecimal.value); confirm the value renders as\u00XXescapes and "Copy Value" yields the on-wire JSON.bun run type:check && bun run lint && bun run testpass in CI.🤖 Generated with Claude Code