gritql icon indicating copy to clipboard operation
gritql copied to clipboard

clearer messages when a referenced file is missing

Open jacobbednarz opened this issue 1 year ago • 7 comments

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?

jacobbednarz avatar Jul 17 '24 11:07 jacobbednarz

/bounty $20

morgante avatar Aug 03 '24 06:08 morgante

💎 $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 bountyShare 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

algora-pbc[bot] avatar Aug 03 '24 06:08 algora-pbc[bot]

/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

asr2003 avatar Aug 03 '24 06:08 asr2003

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

morgante avatar Aug 03 '24 06:08 morgante

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

asr2003 avatar Aug 03 '24 06:08 asr2003

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

morgante avatar Aug 03 '24 07:08 morgante

my first stab at it: https://github.com/getgrit/gritql/pull/479

ORESoftware avatar Aug 29 '24 16:08 ORESoftware

/attempt #423

Algora profile Completed bounties Tech Active attempts Options
@Alex-ley-scrub 1 grit bounty
Rust
Cancel attempt

Alex-ley-scrub avatar Oct 23 '24 22:10 Alex-ley-scrub

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

algora-pbc[bot] avatar Oct 23 '24 22:10 algora-pbc[bot]

🎉🎈 @Alex-ley-scrub has been awarded $20! 🎈🎊

algora-pbc[bot] avatar Oct 24 '24 00:10 algora-pbc[bot]