fix: error expression produces clean message for function values#970
Open
He-Pin wants to merge 1 commit into
Open
fix: error expression produces clean message for function values#970He-Pin wants to merge 1 commit into
He-Pin wants to merge 1 commit into
Conversation
Motivation: `error function(x) x` produced a misleading message like "Couldn't manifest function with params [x]" instead of a clear error about attempting to serialize a function. Modification: Add a Val.Func case to Evaluator.materializeError so that error expressions with function values produce "Couldn't manifest function as JSON" — aligned with go-jsonnet's "couldn't manifest function as JSON" and jrsonnet's "tried to manifest function". Result: `error function(x) x` now produces a clean, implementation-consistent error message instead of leaking internal parameter details. | Impl | Error message | |------|--------------| | go-jsonnet v0.22.0 | RUNTIME ERROR: couldn't manifest function as JSON | | jrsonnet 0.5.0-pre99 | runtime error: tried to manifest function | | sjsonnet (before) | Couldn't manifest function with params [x] | | sjsonnet (after) | Couldn't manifest function as JSON |
b606786 to
dc4424b
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.
Summary
Fix
errorexpression to produce a clean message for function values instead of leaking internal parameter details.Motivation
error function(x) xproduced a misleading message like "Couldn't manifest function with params [x]" instead of a clear error about attempting to serialize a function. Both go-jsonnet and jrsonnet produce cleaner error messages.Modification
Add a
Val.Funccase toEvaluator.materializeErrorso that error expressions with function values produce "Couldn't manifest function as JSON" — aligned with go-jsonnet's "couldn't manifest function as JSON" and jrsonnet's "tried to manifest function".Result
error function(x) xnow produces a clean, implementation-consistent error message instead of leaking internal parameter details.Behavior Comparison
error function(x) xRUNTIME ERROR: couldn't manifest function as JSONRUNTIME ERROR: couldn't manifest function as JSONruntime error: tried to manifest functionsjsonnet.Error: Couldn't manifest function with params [x]sjsonnet.Error: Couldn't manifest function as JSONTest plan
error function(x) xproduces clean error messageerror_function_fail.jsonnetgolden updatederror.error_function.jsonnetadded