Skip to content

Conversation

@gregoryn22
Copy link
Contributor

Summary

This PR improves error handling and robustness for the Kodansha and YenPress metadata providers. It makes the readableUrl field optional in KodanshaBook, simplifies and improves the YenPress first book selection logic, and adds graceful error handling for YenPress series with empty book lists.

Problem

The providers were experiencing issues when:

  1. Kodansha API responses didn't include readableUrl, causing deserialization failures
  2. YenPress series had books without proper number fields, causing crashes when trying to find the first book
  3. YenPress series with empty book lists caused unhandled exceptions that disrupted metadata matching workflows

Changes

1. Made readableUrl Optional in KodanshaBook

  • Added default null value to the readableUrl field in KodanshaBook data class
  • Prevents deserialization failures when the Kodansha API omits this field

Files changed:

  • komf-core/src/commonMain/kotlin/snd/komf/providers/kodansha/model/KodanshaBook.kt

2. Improved YenPress First Book Selection Logic

  • Changed first book selection to check it.number?.start != null instead of it.number != null
  • Added fallback to select any book if no book with a valid number is found
  • Improved error message to include the series ID for better debugging: "No books found for YenPress series ${seriesId.value}"

Files changed:

  • komf-core/src/commonMain/kotlin/snd/komf/providers/yenpress/YenPressMetadataProvider.kt

3. Added Graceful Error Handling for YenPress Empty Book Lists

  • Added specific exception handling in MetadataService for YenPress series with no books
  • When matchSeriesMetadata encounters a YenPress series with no books, it now logs at debug level and skips the provider instead of throwing an error
  • When getSeriesMetadata encounters this case, it re-throws the exception so it can be handled at a higher level
  • Added catch block in launchJob to handle YenPress empty book list exceptions gracefully without emitting error events

Files changed:

  • komf-mediaserver/src/commonMain/kotlin/snd/komf/mediaserver/metadata/MetadataService.kt

Impact

  • Prevents crashes: Kodansha provider no longer crashes when readableUrl is missing from API responses
  • Better book selection: YenPress provider more reliably finds the first book even when number fields are incomplete
  • Improved error handling: YenPress series with empty book lists are handled gracefully without disrupting metadata matching workflows
  • Better debugging: Error messages now include series IDs for easier troubleshooting

Testing

The changes have been tested with:

  • Kodansha API responses missing the readableUrl field
  • YenPress series with books that have incomplete number information
  • YenPress series with empty book lists
  • Metadata matching workflows with various provider combinations

Files Changed

  • komf-core/src/commonMain/kotlin/snd/komf/providers/kodansha/model/KodanshaBook.kt
  • komf-core/src/commonMain/kotlin/snd/komf/providers/yenpress/YenPressMetadataProvider.kt
  • komf-mediaserver/src/commonMain/kotlin/snd/komf/mediaserver/metadata/MetadataService.kt

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