-
Notifications
You must be signed in to change notification settings - Fork 2k
badfiles: added config/cli options to automatically take action on error/warning #6295
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey - I've found 2 issues, and left some high level feedback:
- The logic for detecting warnings/errors by checking if the words 'warning' or 'error' appear in
error_line.lower()is brittle (e.g. localization, different phrasing); consider passing structured severity information from the check instead of inferring it from the message text. - The
handle_import_actionfunction hardcodes the allowed action strings in multiple places; consider centralizing the set of valid actions (e.g. constant or enum-like structure) to avoid drift and to make configuration validation clearer.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The logic for detecting warnings/errors by checking if the words 'warning' or 'error' appear in `error_line.lower()` is brittle (e.g. localization, different phrasing); consider passing structured severity information from the check instead of inferring it from the message text.
- The `handle_import_action` function hardcodes the allowed action strings in multiple places; consider centralizing the set of valid actions (e.g. constant or enum-like structure) to avoid drift and to make configuration validation clearer.
## Individual Comments
### Comment 1
<location> `beetsplug/badfiles.py:230-232` </location>
<code_context>
+
ui.print_(error_line)
+ if found_error and error_action != "ask":
+ return self.handle_import_action(error_action, "error")
+ elif found_warning and warning_action != "ask":
+ return self.handle_import_action(warning_action, "warning")
+
</code_context>
<issue_to_address>
**issue (bug_risk):** Mixed warning/error handling can ignore a stricter warning policy when errors are present.
Given this ordering, when both `found_error` and `found_warning` are true and `error_action != "ask"`, the warning policy is effectively ignored. For instance, with `error_action = "continue"` and `warning_action = "abort"`, execution will continue despite the abort-on-warning configuration. If that’s unintended, consider resolving actions by severity (e.g., assigning priorities and choosing the most conservative) or clearly documenting that error handling always takes precedence over warning handling.
</issue_to_address>
### Comment 2
<location> `docs/plugins/badfiles.rst:37-38` </location>
<code_context>
and errors will be presented when selecting a tagging option.
+`import_action_on_error` and `import_action_on_warning` can be used to take
+automatic action on warning and errors. Both options default to `ask`.
+Valid options for both `import_action_on_(warning|error)` are
+`ask skip abort continue`.
</code_context>
<issue_to_address>
**issue (typo):** Fix grammar in "warning and errors" phrase.
The phrase is grammatically inconsistent; please update it to "automatic action on warnings and errors."
```suggestion
`import_action_on_error` and `import_action_on_warning` can be used to take
automatic action on warnings and errors. Both options default to `ask`.
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
cc00d7b to
6cfb2c0
Compare
|
Sorry for the forced updates, everything is sync'ed with upstream/master now |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6295 +/- ##
==========================================
- Coverage 68.78% 68.69% -0.10%
==========================================
Files 140 140
Lines 18619 18646 +27
Branches 3054 3062 +8
==========================================
+ Hits 12807 12808 +1
- Misses 5164 5190 +26
Partials 648 648
🚀 New features to boost your workflow:
|
|
@snejus What's the proper way to request a review? |
fc9d4d7 to
fd77422
Compare
Description
Updated the
badfilesplugin to support automatic actions taken on warning or error imports, to be used withcheck_on_import: yes.Example usage:
The above configuration will skip badfiles that error out, but ignore any warnings found.
The default for both options is
ask, preserving current behavior.To Do
docs/to describe it.)docs/changelog.rstto the bottom of one of the lists near the top of the document.)Tests. (Very much encouraged but not strictly required.)