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

Fixed an Arcanist crash bug caused by ruleId being null #60

Merged
merged 1 commit into from
Jan 25, 2021

Conversation

tiguchi
Copy link
Contributor

@tiguchi tiguchi commented Jan 25, 2021

There is an edge case while running ESlint that can cause Arcanist to crash with the following error message:

Linter "ESLintLinter" generated a lint message that is invalid because it does not have a name. Lint messages must have a name.

This edge case can be triggered by trying to lint a source file with a syntax error in it. That produces an ESlint JSON output where ruleId is null.

The idx function however does not fall back to using the provided default value 'unknown'.
It does actually the following: if the dictionary property value is null, and if the tested key (here ruleId) exists in the dictionary, then it returns null instead of the fallback default value.

This fix makes sure we never set a null value for the name property.

Testing

  • Ran arc lint in a local project with a modified JS source file that has a syntax error in it. Arcanist does not crash anymore with this fix

@tiguchi tiguchi requested a review from jparise as a code owner January 25, 2021 20:39
Copy link
Collaborator

@jparise jparise left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for describing the failure case so specifically!

src/ESLintLinter.php Outdated Show resolved Hide resolved
There is an edge case while running ESlint that can cause Arcanist to crash with the following error message:

> Linter "ESLintLinter" generated a lint message that is invalid because it does not have a name. Lint messages must have a name.

This edge case can be triggered by trying to lint a source file with a syntax error in it. That produces an ESlint JSON output where ruleId is null.

The idx function however does not fall back to using the provided default value 'unknown'.
It does actually the following: if the dictionary property value is null, and if the tested key (here ruleId) exists in the dictionary, then it returns null instead the fallback default value.

This fix makes sure we never set a null value for the name property.
@tiguchi tiguchi force-pushed the fix/eslint-parse-error-handling branch from a20afa4 to 10fe057 Compare January 25, 2021 22:48
@jparise jparise merged commit 3ae644e into pinterest:master Jan 25, 2021
@jparise
Copy link
Collaborator

jparise commented Jan 25, 2021

Thanks again, @tiguchi!

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.

2 participants