Skip to content

Use source locations for parser errors - #891

Open
fly1d wants to merge 1 commit into
lightbend:mainfrom
fly1d:fix/parser-error-lines
Open

fly1d wants to merge 1 commit into
lightbend:mainfrom
fly1d:fix/parser-error-lines

Conversation

@fly1d

@fly1d fly1d commented Oct 28, 2026

Copy link
Copy Markdown

Fixes #885.

After a multiline string, an invalid URL include on line 5 is reported as line 2. ConfigParser builds semantic errors from a counter that only sees newline nodes, missing newlines embedded in quoted tokens.

Use the offending include or field node's first positioned token for the error origin, falling back to the existing counter when no token has a location. This also handles preceding multiline keys, without changing tokenizer or value/object/array origins. Existing messages and causes are preserved.

Validation on macOS arm64:

  • Temurin 11, sbt 1.11.2: test doc passed, with 607 tests and successful API documentation generation.
  • Three new test methods cover 11 inputs. With pristine production code, the two multiline regressions fail and the escaped-newline control passes; the fixed ConfParserTest passes all 46 tests.
  • Two separate public API programs on JDK 17 check 16 scenarios, including CRLF, concatenation, nested values, multiline keys, file/custom origins and an unresolved include inside a list. The original code fails 11 scenarios; the fix passes all 16.

Related work in the Scala port: ekrich/sconfig#641. This PR is limited to the Java parser and its tests. Java 8 and Linux/Windows execution were not tested locally.

@lightbend-cla-validator

Copy link
Copy Markdown
Collaborator

Hi @fly1d,

Thank you for your contribution! We really value the time you've taken to put this together.

Before we proceed with reviewing this pull request, please sign the Akka Contributors License Agreement:

https://contribute.akka.io/contribute/cla

This branch has not been deployed

No deployments
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.

Parse errors after a multi-line string report a line number that is too small

2 participants