Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clearer messages when a referenced file is missing #423

Open
jacobbednarz opened this issue Jul 17, 2024 · 7 comments
Open

clearer messages when a referenced file is missing #423

jacobbednarz opened this issue Jul 17, 2024 · 7 comments
Labels

Comments

@jacobbednarz
Copy link

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 morgante added the good first issue Good for newcomers label Aug 3, 2024
@morgante
Copy link
Contributor

morgante commented Aug 3, 2024

/bounty $20

Copy link

algora-pbc bot commented Aug 3, 2024

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

@asr2003
Copy link

asr2003 commented Aug 3, 2024

/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
Copy link
Contributor

morgante commented Aug 3, 2024

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

@asr2003
Copy link

asr2003 commented Aug 3, 2024

@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
Copy link
Contributor

morgante commented Aug 3, 2024

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

@ORESoftware
Copy link

my first stab at it: #479

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants