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

Incorrect assumption that all media_fields are fixed fields #5581

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions beets/ui/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1631,8 +1631,8 @@ def update_items(lib, query, album, move, pretend, fields, exclude_fields=None):
# database.
fields.append("path")
if fields is None:
# no fields were provided, update all media fields
item_fields = fields or library.Item._media_fields
# no fields were provided, update all fields
item_fields = fields or library.Item._fields.keys()
Copy link
Preview

Copilot AI Mar 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using library.Item._fields.keys() returns a view which may not support the add method later when 'move' is true. Consider converting it to a modifiable type (e.g., a set) before attempting to add the 'path' field.

Suggested change
item_fields = fields or library.Item._fields.keys()
item_fields = fields or set(library.Item._fields.keys())

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot is right — this needs to be a set, see the next line where another field is added into it.

if move and "path" not in item_fields:
# move is enabled, add 'path' to the list of fields to update
item_fields.add("path")
Expand Down