badfiles: added config/cli options to automatically take action on error/warning#6295
Open
tommyschnabel wants to merge 6 commits intobeetbox:masterfrom
Open
badfiles: added config/cli options to automatically take action on error/warning#6295tommyschnabel wants to merge 6 commits intobeetbox:masterfrom
tommyschnabel wants to merge 6 commits intobeetbox:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
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
Author
|
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 69.33% 69.24% -0.10%
==========================================
Files 141 141
Lines 18793 18820 +27
Branches 3061 3069 +8
==========================================
+ Hits 13031 13032 +1
- Misses 5117 5143 +26
Partials 645 645
🚀 New features to boost your workflow:
|
Author
|
@snejus What's the proper way to request a review? |
fc9d4d7 to
fd77422
Compare
Member
|
@tommyschnabel review is automatically requested from @beetbox/maintainers when you submit a PR! You want to fix the issues with the CI now, I think. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.)