Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve YAML parsing error messages #18

Open
aschaal opened this issue Oct 25, 2024 · 1 comment
Open

Improve YAML parsing error messages #18

aschaal opened this issue Oct 25, 2024 · 1 comment
Assignees
Labels
dim This issue is about the Dim tool enhancement New feature or request

Comments

@aschaal
Copy link
Collaborator

aschaal commented Oct 25, 2024

Wrong number of spaces may lead to this error message:
“did not find expected key while parsing a block mapping at line 1 column 1”

See also wrong line reported in 'did not find expected key while parsing a block mapping' · Issue #190 · ruby/psych

It would be nice to manually parse the YAML file when this error is returned to find the first occurrence where spaces before attributes are not correct to give the user a better hint where to look.

@aschaal aschaal added enhancement New feature or request dim This issue is about the Dim tool labels Oct 25, 2024
@aschaal
Copy link
Collaborator Author

aschaal commented Oct 25, 2024

In order to print the correct error message we will have to monkey patch the Psych and that should not cause any concerns as we will be updating the just the line number from the error message which we can find from psych handler.

But main challenge is the method that we are monkey patching i.e. Psych::Parser#parse. In Psych 4 this is coming from C code(PR) and monkey patching that we are hoping for will only be possible if we update underlying Psych to >= 5.

This can be done by adding runtime dependency in gemspec, but need to verify if this is the right approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dim This issue is about the Dim tool enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants