Skip to content

fix: improve base64 and decodeUTF8 error messages#1043

Open
He-Pin wants to merge 1 commit into
databricks:masterfrom
He-Pin:fix/error-messages-go-jsonnet
Open

fix: improve base64 and decodeUTF8 error messages#1043
He-Pin wants to merge 1 commit into
databricks:masterfrom
He-Pin:fix/error-messages-go-jsonnet

Conversation

@He-Pin

@He-Pin He-Pin commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fixes base64 error classification to use UTF-8 byte length instead of UTF-16 code-unit length.
  • Keeps the UTF-8 byte-length heuristic allocation-free instead of calling getBytes on the error path.
  • Restores decodeUTF8 element-index reporting and uses stable numeric rendering for array element values.
  • Adds a raw-byte fast path for decodeUTF8; otherwise validates and fills the byte array in a single indexed pass.
  • Moves renderer long scratch buffers from shared companion state to renderer instances so independent interpreters do not share mutable scratch memory.
  • Restores the agent-facing threading-model note in CLAUDE.md.

Current head: b794c651c7bc8416d3e66fdf752f3563c0632854

Performance Notes

  • Base64 string classification scans chars once and does not allocate a temporary UTF-8 byte array.
  • decodeUTF8 avoids iterator/zipWithIndex/map pipelines in the validation path.
  • The byte-array-backed path decodes directly from rawBytes.
  • Renderer scratch buffers are one tiny allocation per renderer instance, not shared global mutable state and not per number.

Verification

  • rtk ./mill --no-daemon 'sjsonnet.jvm[3.3.8].reformat'
  • rtk ./mill --no-daemon 'sjsonnet.jvm[3.3.8].checkFormat'
  • rtk ./mill --no-daemon 'sjsonnet.js[2.13.18].checkFormat'
  • rtk ./mill --no-daemon 'sjsonnet.jvm[3.3.8].test' sjsonnet.Base64Tests
  • rtk ./mill --no-daemon 'sjsonnet.jvm[3.3.8].test' sjsonnet.StdStringTests
  • rtk ./mill --no-daemon 'sjsonnet.jvm[3.3.8].test' sjsonnet.FileTests
  • rtk ./mill --no-daemon 'sjsonnet.js[2.13.18].test' sjsonnet.Base64Tests
  • rtk ./mill --no-daemon 'sjsonnet.js[2.13.18].test' sjsonnet.StdStringTests
  • rtk ./mill --no-daemon 'sjsonnet.js[2.13.18].test' sjsonnet.FileTests
  • rtk ./mill --no-daemon 'sjsonnet.wasm[2.13.18].test' sjsonnet.Base64Tests
  • rtk ./mill --no-daemon 'sjsonnet.wasm[2.13.18].test' sjsonnet.StdStringTests
  • rtk ./mill --no-daemon 'sjsonnet.wasm[2.13.18].test' sjsonnet.FileTests
  • rtk ./mill --no-daemon 'sjsonnet.native[2.13.18].compile'
  • Qoder stdout review of the final diff: no must-fix findings.

@He-Pin He-Pin force-pushed the fix/error-messages-go-jsonnet branch 2 times, most recently from 3757010 to ac56108 Compare June 25, 2026 07:46
@He-Pin He-Pin changed the title fix: align error messages with go-jsonnet format fix: improve base64 and decodeUTF8 error messages Jun 25, 2026
@He-Pin He-Pin marked this pull request as ready for review June 25, 2026 08:33
@He-Pin He-Pin marked this pull request as draft June 25, 2026 17:57
@He-Pin He-Pin marked this pull request as ready for review June 25, 2026 18:34
@He-Pin He-Pin force-pushed the fix/error-messages-go-jsonnet branch from d1df400 to 3163994 Compare June 25, 2026 19:04
Use allocation-free UTF-8 byte-length accounting for base64 string error heuristics.

Keep decodeUTF8 validation single-pass and preserve original element indexes and values across JVM, JS, and WASM.

Keep renderer integer scratch buffers interpreter-local instead of global mutable state.
@He-Pin He-Pin force-pushed the fix/error-messages-go-jsonnet branch from 3163994 to b794c65 Compare June 25, 2026 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant