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

Fix parsing maxAllowedComplexity #646

Merged
merged 1 commit into from
Nov 1, 2023

Conversation

arendjr
Copy link
Contributor

@arendjr arendjr commented Nov 1, 2023

Fixes #643.

Summary

So apparently there's a confusing behavior where the SyntaxNode of a JsonNumberValue may contain a trailing space. If it does, calling .to_string() on the syntax node will include the space, causing u8::from_str() to fail. Calling .text() directly on the value doesn't have this issue.

To be honest, it feels like this may be a workaround to a deeper issue, so I'm not entirely sure this is the right fix. Because of this, I also have not yet created a test for it. Is the possibility for trailing spaces in syntax nodes an expected behavior?

Test Plan

I think an extra unit test should be created for this, since it's quite surprising behavior. But right now I'm more concerned about how similar issues could be prevented from (re)occurring. But the right action here depends on whether the spaces in syntax nodes are intentional or not.

@github-actions github-actions bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Nov 1, 2023
@ematipico
Copy link
Member

That's a bug from our end. We used the incorrect APIs to represent the information.

@ematipico ematipico merged commit a3ef0ef into biomejs:main Nov 1, 2023
12 checks passed
@arendjr arendjr deleted the fix-config-number-parsing branch November 1, 2023 08:59
@Conaclos Conaclos added the A-Changelog Area: changelog label Nov 23, 2023
ematipico pushed a commit that referenced this pull request May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Changelog Area: changelog A-Linter Area: linter L-JavaScript Language: JavaScript and super languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛maxAllowedComplexity doesn’t pass validation
3 participants