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

Conversation

pvliesdonk
Copy link

Description

Fixes #5580

(...)

To Do

  • Documentation. (If you've added a new command-line flag, for example, find the appropriate page under docs/ to describe it.)
  • Changelog. (Add an entry to docs/changelog.rst to the bottom of one of the lists near the top of the document.)
  • Tests. (Very much encouraged but not strictly required.)

Copy link

github-actions bot commented Jan 6, 2025

Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry.

@snejus snejus requested a review from Copilot March 12, 2025 06:03
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses the incorrect assumption that all media fields are fixed by updating the logic that determines which fields to update when no fields are provided. Key changes include:

  • Removing the dependency on library.Item._media_fields.
  • Using library.Item._fields.keys() to obtain the list of all fields.
  • Ensuring that the 'path' field is included when the move option is enabled.

# 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.

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.

@snejus
Copy link
Member

snejus commented Mar 12, 2025

How is this going to prevent the OperationalError that you've seen, where the custom field is not found?

It would be good to include a note in the changelog as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update mediafields regression
2 participants