getgrit / gritql

GritQL is a query language for searching, linting, and modifying code.
https://docs.grit.io/
MIT License
3.12k stars 77 forks source link

clearer messages when a referenced file is missing #423

Closed jacobbednarz closed 6 days ago

jacobbednarz commented 3 months ago

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?
morgante commented 2 months ago

/bounty $20

algora-pbc[bot] commented 2 months ago

πŸ’Ž $20 bounty β€’ Grit

Steps to solve:

  1. Start working: Comment /attempt #423 with your implementation plan
  2. Submit work: Create a pull request including /claim #423 in the PR body to claim the bounty
  3. 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
asr2003 commented 2 months ago

/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
morgante commented 2 months ago

Thanks @asr2003, please be sure to include an integration test in https://github.com/getgrit/gritql/tree/main/crates/cli_bin/tests

asr2003 commented 2 months ago

@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?

morgante commented 2 months ago

You need to solve the issue. I'm not going to handhold you through every detail.

ORESoftware commented 2 months ago
Alex-ley-scrub commented 1 week ago

/attempt #423

Algora profile Completed bounties Tech Active attempts Options
@Alex-ley-scrub 1 grit bounty
Rust
Cancel attempt
algora-pbc[bot] commented 1 week ago

πŸ’‘ @Alex-ley-scrub submitted a pull request that claims the bounty. You can visit your bounty board to reward.

algora-pbc[bot] commented 6 days ago

πŸŽ‰πŸŽˆ @Alex-ley-scrub has been awarded $20! 🎈🎊