-
-
Notifications
You must be signed in to change notification settings - Fork 135
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
check_module: Don't crash, exit with error instead #261
Conversation
Codecov Report
@@ Coverage Diff @@
## master #261 +/- ##
==========================================
- Coverage 88.03% 87.31% -0.72%
==========================================
Files 6 6
Lines 660 670 +10
==========================================
+ Hits 581 585 +4
- Misses 79 85 +6
Continue to review full report at Codecov.
|
@evanunderscore can you please take a look at this? Code in question was introduced in #204. |
I had assumed that Having said that, failing with an exception is something this script is designed to do in any number of error cases. I don't know anything about Fedora's automatic bug reporting - what exactly is triggering that? How does it decide which kind of failures need to be reported? Looking at the user's description, I can see why this is happening in his particular case, and I can probably come up with a patch that checks how many arguments have been passed before trying to invoke some of these completion methods, but there are still other expected failure cases that will likely trigger this reporting mechanism, so I'd like to get to the bottom of that if possible. Can you provide any insight @hroncok? |
The Fedora's automatic bug reporting recognizes if a program crashes with a traceback on stderr and non-0 exit code. It usually means a problem. If exiting with non-0 is desired here, to avoid the report, the code would need to catch the exception and report the error via print to stdout or similar. I can send a PR, but I'd like to know first: how is this failure detected elsewhere? |
Something like this:
try:
main()
except RuntimeError as e:
print(e, file=sys.stderr)
sys.exit(1) |
This is an internal function that is run by the global completion function to check whether a given module is compatible with argcomplete. You can see where it is invoked here:
If it's the only way to avoid the automatic bug report, then yes, we'd have to catch the exceptions and explicitly exit with a non-zero error code instead. In your snipped above, Would you be happy to implement that? |
I would! Thanks. |
Done. |
@hroncok Thanks for your work on this, the changes look good to me. Up to you whether you want to do anything about the remaining unresolved comments. Let me know when you're ready for me to merge. |
I will address the comments. |
@hroncok Please update with the preferred wording for the error name. Otherwise, is this good to merge? |
(Sorry about the delay in my response.) |
Released in v1.9.5, please test. |
I'll update the Fedora package and hopefully those reports will stop. |
This should avoid https://bugzilla.redhat.com/show_bug.cgi?id=1689507
I still don't know what makes this happen, or if a regular Exception is better here than AttributeError, but this is not the first time this was reported by Fedora automatic bug report.
See for example https://bugzilla.redhat.com/show_bug.cgi?id=1601763
I've asked the user what were they actually doing.
https://retrace.fedoraproject.org/faf/reports/2267286/ gives hint that this happens quite often.