Skip to content

Preserve unknown credit roles instead of crashing during import - #39

Open
ArkhanLand wants to merge 1 commit into
dickloraine:masterfrom
ArkhanLand:fix/preserve-unknown-credit-roles
Open

ArkhanLand wants to merge 1 commit into
dickloraine:masterfrom
ArkhanLand:fix/preserve-unknown-credit-roles

Conversation

@ArkhanLand

Copy link
Copy Markdown

Importing ComicBookInfo credits can raise AttributeError: 'NoneType' object has no attribute 'lower' when a person already has another credit and an incoming role is absent from credit_synonyms. get_role_from_synonyms() turns that role into None, which addCredit() then compares with existing roles. Without a matching person, the same role is silently dropped instead.

Observed while importing Marvel metadata with roles such as painter, penciller (cover), and colorist (cover) in plugin 1.6.9 / Calibre 9.15.0. A minimal reproduction is adding a Writer credit for Mike Del Mundo, then overlaying his painter credit.

This change preserves unrecognized nonempty role strings while keeping known synonym normalization. It also rejects missing/empty roles before duplicate comparison in addCredit(). Case-insensitive deduplication and primary-credit updates continue to work.

Adds six standard-library regression tests for the crash, unknown-role preservation, duplicate handling, known synonyms, role-specific overlay replacement, and missing roles. They import the actual metadata class with only its Calibre formatting-helper dependency stubbed.

Validation:

  • python -m unittest discover -s tests -v: all 6 tests pass on Python 3.14.7; the suite fails against unmodified upstream.
  • git diff --check: passes.

Scope: preservation is in the shared metadata model. This does not add new Calibre custom-column mappings or make ComicInfo.xml represent arbitrary roles. Live Calibre GUI validation of this patch has not yet been performed.

@ArkhanLand
ArkhanLand marked this pull request as draft September 30, 2026 05:54
@ArkhanLand
ArkhanLand marked this pull request as ready for review September 30, 2026 06:01
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.

1 participant