gritql
gritql copied to clipboard
clearer messages when a referenced file is missing
Earlier today, I was updating some patterns and when I went to run grit patterns test hit the following.
$ grit patterns test
Error: No such file or directory (os error 2)
I did all the usual things thinking this was something I broke in my environment (somehow lost grit) however, that all looked good. After a while, I busted out strace and it turned out this came from grit trying to look up a file in the pattern.
$ strace -f -e trace=open,openat ~/.grit/bin/grit patterns test
.. snip
[pid 799] openat(AT_FDCWD, "/mnt/share/.grit/grit.yaml", O_RDONLY|O_CLOEXEC) = 9
[pid 799] openat(AT_FDCWD, "/mnt/share/.grit/../docs/guides/version_5_upgrade.m", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid 798] +++ exited with 0 +++
[pid 797] +++ exited with 0 +++
[pid 791] +++ exited with 0 +++
[pid 799] +++ exited with 0 +++
Error: No such file or directory (os error [pid 799] openat(AT_FDCWD, "/mnt/share/.grit/../docs/guides/version_5_upgrade.m", O_RDONLY) = -1 ENOENT (No such file or directory)
2)
.. snip
Yep, I did a stupid and removed a trailing letter of the file extension.
To make this easier to debug for others, perhaps wrapping this sort of error up in a nicer handler would be useful? Something like this would be helpful:
$ grit patterns test
Failed to find pattern at "/mnt/share/.grit/../docs/guides/version_5_upgrade.m". Does it exist?
/bounty $20
💎 $20 bounty • Grit
Steps to solve:
- Start working: Comment
/attempt #423with your implementation plan - Submit work: Create a pull request including
/claim #423in the PR body to claim the bounty - Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts
Thank you for contributing to getgrit/gritql!
Add a bounty • Share on socials
| Attempt | Started (GMT+0) | Solution |
|---|---|---|
| 🟢 @asr2003 | Aug 3, 2024, 6:27:27 AM | WIP |
| 🟢 @Alex-ley-scrub | Oct 23, 2024, 10:27:29 PM | #558 |
/attempt #423
@morgante Will add error handling in analyse.rs file to handle the issue of missing file references and to enhance the error handling within the walk_call_tree and find_child_tree_definition functions
| Algora profile | Completed bounties | Tech | Active attempts | Options |
|---|---|---|---|---|
| @asr2003 | 2 bounties from 2 projects | JavaScript, Go, HTML & more |
Cancel attempt |
Thanks @asr2003, please be sure to include an integration test in https://github.com/getgrit/gritql/tree/main/crates/cli_bin/tests
@morgante I have seen two related files of it. crates\cli\src\commands\patterns.rs crates\core\src\analysis.rs
Do I make changes to both files or patterns.rs is fine?
You need to solve the issue. I'm not going to handhold you through every detail.
my first stab at it: https://github.com/getgrit/gritql/pull/479
/attempt #423
| Algora profile | Completed bounties | Tech | Active attempts | Options |
|---|---|---|---|---|
| @Alex-ley-scrub | 1 grit bounty | Rust |
Cancel attempt |
💡 @Alex-ley-scrub submitted a pull request that claims the bounty. You can visit your bounty board to reward.