Fix --string non-string error reporting#1039
Open
He-Pin wants to merge 2 commits into
Open
Conversation
Motivation: --string mode should reject non-string manifests with a normal Jsonnet-style error. Upstream sjsonnet only special-cased null with upickle.core.Abort, so other non-string values leaked as Internal error output with upickle details. Modification: Make the --string renderer throw sjsonnet.Error for every non-string visitor path, preserving string output unchanged and mapping non-string values to object/array/number/boolean/null. Add a CLI jsonnet+golden regression and tighten existing exec --string assertions. Result: Non-string --string outputs now fail with a clean sjsonnet.Error and no Internal error or upickle.core.Abort leakage across file and --exec inputs.
2dd17d0 to
cedccb2
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
--stringmode leakedInternal error: upickle.core.Abortwhen the Jsonnet program produced a non-string result (object, array, number, boolean, null). Other implementations report a clean type error. The error path also lost the source position, making debugging harder.--stringon{}ERROR: expected string result, got: objectexpected string result, got: objectInternal error: upickle.core.Abortexpected string result, got: objectModification
SimpleVisitorthat threwupickle.core.Abortwith a typed visitor that overrides every non-string visitor method to throwsjsonnet.Errorwith a clear message including the Jsonnet type name (object,array,number,boolean,null).returnkeyword inManifestModule.scalamatch expression for idiomatic Scala.--exec --stringtests.Result
sjsonnet.Errorwith position and Jsonnet type name.fillInStackTraceoverride prevents wasted JVM stack capture.