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

magika -r /nonexistant exits with 0 #780

Closed
reyammer opened this issue Nov 1, 2024 · 2 comments · Fixed by #784
Closed

magika -r /nonexistant exits with 0 #780

reyammer opened this issue Nov 1, 2024 · 2 comments · Fixed by #784
Labels
rust Pull requests that update Rust code

Comments

@reyammer
Copy link
Collaborator

reyammer commented Nov 1, 2024

Consider:

$ uv run magika -r tests_data
tests_data: No such file or directory (os error 2) (error)
$ echo $?
0

This currently exits with 0. I would have expected an error code (this is one of the assumption for the gh workflow test suite).

Unclear what's the cleanest thing to do. If there at least one file that gets predicted without errors we could still return 0; but it's weird to return "no problems" when there is not a single file that has been successfully scanned? Maybe we return non-zero if no files has been scanned; zero otherwise?

Thoughts @ia0?

@reyammer reyammer added the rust Pull requests that update Rust code label Nov 1, 2024
@ia0
Copy link
Member

ia0 commented Nov 1, 2024

Nice catch. I see multiple options which can be controlled by a flag:

  • non zero code is at least one error (should probably the default)
  • non zero code if only errors (not convinced it's useful)
  • non zero code if internal error only (current behavior I guess)

I would personally be fine with only the first option and no flag.

reyammer added a commit that referenced this issue Nov 1, 2024
@reyammer
Copy link
Collaborator Author

reyammer commented Nov 1, 2024

I like the first option.

To be specific, we could do: in case of errors with a one or more files, I would anyways keep going forward and scan everything we can, and just exit 1 at the very end to signal "something went wrong with at least one file", where "went wrong" means something like permission error, file does not exist, and the like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants