fix: prevent ariadne from panicking on empty stdin/file#1588
Open
daschinmoy21 wants to merge 4 commits intomolybdenumsoftware:masterfrom
Open
fix: prevent ariadne from panicking on empty stdin/file#1588daschinmoy21 wants to merge 4 commits intomolybdenumsoftware:masterfrom
daschinmoy21 wants to merge 4 commits intomolybdenumsoftware:masterfrom
Conversation
Member
|
How about a test for this? |
Author
|
Yea exactly i actually made a test last night. Will raise a pr in the evening after college ends |
0f1a07c to
11230da
Compare
mightyiam
reviewed
Apr 8, 2026
mightyiam
reviewed
Apr 9, 2026
821c749 to
544dcf8
Compare
mightyiam
reviewed
Apr 10, 2026
Member
|
Some conflicts |
Author
|
On it |
When statix receives an empty string via stdin, an empty Report is generated. Passing an empty string to ariadne's Source::from causes an index out of bounds panic. Supplying a string with a single space as a fallback prevents this panic while keeping the error location at byte offset 0.
544dcf8 to
f8088d2
Compare
Author
|
Should be good now. handles empty stdin and files now. Now it returns |
mightyiam
reviewed
Apr 23, 2026
Comment on lines
-52
to
+56
| let range = |at: TextRange| at.start().into()..at.end().into(); | ||
| let src_id = path.to_str().unwrap_or("<unknown>"); | ||
| if src.is_empty() { | ||
| return write_empty_stderr(writer, lint_result, src_id); | ||
| } | ||
| let range = |at: TextRange| at.start().into()..at.end().into(); |
Member
There was a problem hiding this comment.
I'm picking up a certain smell here; isn't it strange that a LintResult exists for an empty source? I think an empty source should fail to parse. Does rnix successfully parse an empty string?
Author
There was a problem hiding this comment.
Yes rnix parses it. returns a ParseError::UnexpectedEOF
Member
There was a problem hiding this comment.
So why are we getting this far in execution where a LintResult seems to exist?
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.
Fixes oppiliappan#78
When statix receives an empty string via stdin, an empty Report is generated. Passing an empty string to ariadne's Source::from causes an index out of bounds panic. Supplying a string with a single space as a fallback prevents this panic while keeping the error location at byte offset 0.
Output after this fix-
echo "" | nix run . -- check -s
[E00] Error: Syntax error
╭─[:1:1]
│
1 │
· │
· ╰─ Unexpected end of file
───╯