Handle newer Goodreads export formats while still allowing old ones#1801
Conversation
The three provider id_from_isbn methods silently swallowed HTTP request and JSON parse errors via .ok()? before returning None, making it impossible to diagnose why an ISBN lookup failed. Replace the .ok()? calls with explicit match arms that log the actual error via tracing::warn! before returning None. Also add #[tracing::instrument] to the coordinating function get_identifier_from_book_isbn so the ISBN value is captured in the span and each provider failure is logged at the call site.
WalkthroughGoodreads imports now limit concurrent processing, normalize and validate ISBN values, and safely parse multiple ChangesGoodreads import processing
Trakt request formatting
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/utils/dependent/provider/src/lib.rs`:
- Line 160: Update the tracing instrument annotation on the provider function to
explicitly record the `isbn` argument value, rather than only declaring an empty
field. Preserve `skip_all` and ensure nested provider warnings retain the ISBN
context.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: f7c2c2a6-274c-4565-9c73-f665aa9b4e52
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (7)
crates/providers/google-books/Cargo.tomlcrates/providers/google-books/src/lib.rscrates/providers/hardcover/src/base.rscrates/providers/openlibrary/src/client.rscrates/services/importer/trakt/src/lib.rscrates/utils/dependent/provider/Cargo.tomlcrates/utils/dependent/provider/src/lib.rs
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/services/importer/goodreads/src/lib.rs`:
- Around line 153-162: Guard the ended_on assignment in the date_read parsing
block by handling an empty seen_history before calling first_mut().unwrap(). For
read_count == 0, reject the inconsistent row as InputTransformation or otherwise
follow the existing empty-history handling path; only assign ended_on when a
first history entry exists.
- Around line 107-120: Update the ISBN validation near the `isbn` normalization
and before `get_identifier_from_book_isbn` so non-empty values must contain
exactly 13 ASCII digits, or apply the repository’s intended ISBN check-digit/GS1
validation. Preserve the existing `ImportFailedItem` error path and prevent
malformed values such as `123` from reaching provider lookup.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: cc7801fb-7698-4b7d-9494-35f7529727e7
📒 Files selected for processing (1)
crates/services/importer/goodreads/src/lib.rs
The three provider id_from_isbn methods silently swallowed HTTP request and JSON parse errors via .ok()? before returning None, making it impossible to diagnose why an ISBN lookup failed.
Replace the .ok()? calls with explicit match arms that log the actual error via tracing::warn! before returning None. Also add #[tracing::instrument] to the coordinating function get_identifier_from_book_isbn so the ISBN value is captured in the span and each provider failure is logged at the call site.
Summary by CodeRabbit