fix: parse errors show meaningful messages instead of internal 'fail' label#1022
Merged
stephenamar-db merged 1 commit intoJun 24, 2026
Merged
Conversation
… label
Motivation:
Parse errors exposed fastparse's internal combinator name "fail"
(e.g., "Expected fail:1:12"), which is meaningless to users.
Root cause: Several parser rules used bare `Fail` instead of
`Fail.opaque("descriptive message")`, causing fastparse to use
the default "fail" label in error messages.
Fix: Replace bare `Fail` with descriptive `Fail.opaque(...)`:
- String literal parsing: "string literal"
- Verbatim string (@): "verbatim string literal (@\" or @')"
- Expression parsing: "expression"
Result:
- Before: "Expected fail:1:12, found ..."
- After: "Expected expression:1:12, found ..."
Also includes error test files for format %c validation (from PR databricks#1015).
Cross-implementation comparison (local x = ; x):
| Implementation | Error message |
|---|---|
| C++ jsonnet | "unexpected: \";\" while parsing terminal" |
| go-jsonnet | "Unexpected: \";\" while parsing terminal" |
| sjsonnet (before) | "Expected fail:1:12" |
| sjsonnet (after) | "Expected expression:1:12" ✅ |
stephenamar-db
approved these changes
Jun 24, 2026
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.
fix: parse errors show meaningful messages instead of internal "fail" label
Motivation
Parse errors exposed fastparse's internal combinator name
"fail"(e.g.,Expected fail:1:12), which is meaningless to users. Root cause: several parser rules used bareFailinstead ofFail.opaque("descriptive message").Modification
Parser.scala: Replaced 5 bareFailwith descriptiveFail.opaque(...):"string literal"@) →"verbatim string literal (@\" or @')""expression"Result
local x = ; xExpected fail:1:12❌Expected expression:1:12✅@helloExpected fail:1:2❌Expected verbatim string literal✅{a: }Expected fail:1:6❌Expected expression:1:6✅