fix: unify and improve error-message quality across sjsonnet#1010
Open
He-Pin wants to merge 1 commit into
Open
fix: unify and improve error-message quality across sjsonnet#1010He-Pin wants to merge 1 commit into
He-Pin wants to merge 1 commit into
Conversation
7 tasks
He-Pin
added a commit
to He-Pin/sjsonnet
that referenced
this pull request
Jun 20, 2026
Motivation: The std namespace in Jsonnet is always lowercase. PR databricks#1010 incorrectly capitalized it as Std.* in error messages during the capitalization unification. Modification: Replace all Std.* references with std.* in error messages, golden test files, and test assertions. Result: Error messages correctly reference std.* functions with lowercase namespace, matching the Jsonnet language specification.
b7856cf to
72a3dcd
Compare
ec7a543 to
ce15b64
Compare
ce15b64 to
82e7c9c
Compare
Motivation:
Error messages had inconsistent casing, missing context (function name,
parameter name, actual values), and in some cases exposed Java internals
(.getClass instead of .prettyName). This made debugging Jsonnet programs
frustrating.
Modification:
1. Capitalization: Every error message starts with a capital letter,
while preserving exact casing for stdlib identifiers (assertEqual,
manifestYamlStream, quote_keys, keyF).
2. Function context: Added std.<functionName>: prefix to ~40 messages
across ArrayModule, SetModule, ManifestModule, MathModule,
StringModule, and Format.scala.
3. Actual values: Replaced .getClass with .prettyName for readable
type names. Added actual values to removeAt (idx + array length),
codepoint (string length), and flattenArrays (element types).
4. Clarity: Rewrote confusing messages:
- flattenArrays: "Binary operator +" → "cannot concatenate — arrays
contain incompatible types"
- validateSet: "Set operation on X was called with a non-set" →
"second argument must be a sorted array without duplicates"
- Format: "at N" → "at position N" for clarity
5. Removed Java internals: .getClass → .prettyName in ManifestModule
(3 locations), .getClass → ujsonTypeName() in manifestXmlJsonml.
Result:
All ~95 error messages now include function context, use readable type
names, and start with a capital letter. Stdlib identifiers retain their
documented casing. 83 files changed (13 source + 37 golden + 7 test).
82e7c9c to
41ce83e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Error messages across sjsonnet were inconsistent: some included
std.<name>prefixes, some did not; some leaked.getClassoutput;some produced misleading or generic messages. This made debugging
Jsonnet programs harder and diverged from go-jsonnet's style.
Modification
in
Error.scala.removeAt,codepoint, andflattenArrayserrors..getClassleaks from error messages.Result
More informative, consistent error messages across the stdlib.
Improved debuggability for users. All tests pass on JVM / JS / Wasm /
Native / Graal.
References