-
Notifications
You must be signed in to change notification settings - Fork 657
fix(rome_service): disallow large files from being parsed and analyzed #3339
Conversation
✅ Deploy Preview for rometools canceled.
|
9478178
to
568655d
Compare
```block | ||
ci.js lint ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
|
||
× The file ci.js could not be parsed because it's too large (the file is 1.0 MiB long, but the size limit is 1.0 MiB) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a coincidence that the input file is 1.0
Megabyte like the limit? If not, probably that's because we truncated some digits. I am not sure what to do... surely an inexperienced user might think that's a bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit of both, in this case the test file is a few bytes larger than 1 MiB but that doesn't show since the values higher than 1 KiB are not printed at full precision. However the file size limit is checked using >=
so even a file that's precisely 1 MiB in size would be rejected and print the error anyway.
568655d
to
47e475e
Compare
Summary
Fixes #3330
This PR adds a maximum size threshold to the Workspace after which files are no longer parsed, analyzed or formatted. At the moment I've hard-coded this limit to 1 MiB, but it should be trivial to expose this limit in the configuration file or the CLI if users really want to process very large files.
As part of the new message for this new error, I've added a new
Bytes
utility torome_console
that prints a quantity in bytes using the correct binary unit (B, KiB, MiB, GiB or TiB)Test Plan
I've added new test cases for the CLI that ensures files larger than the size threshold are not checked or formatted, and the correct diagnostic is emitted.