Skip to content

Fix: Handle invalid data in build_movies#128

Merged
glensc merged 2 commits into
mainfrom
ignore-build-movies-errors
Jul 13, 2026
Merged

Fix: Handle invalid data in build_movies#128
glensc merged 2 commits into
mainfrom
ignore-build-movies-errors

Conversation

@glensc

@glensc glensc commented Jul 13, 2026

Copy link
Copy Markdown
Owner

/users/me/collection/movies?extended=metadata endpoint seems to be buggy:

  1. contains entries that appear empty: {'type': 'movie', 'collected_at': '2016-11-21T15:55:31.000Z', 'updated_at': '2019-02-03T16:31:47.000Z', 'available_on': [], 'metadata': None, 'movie': {'ids': {'imdb': None, 'plex': {'guid': None, 'slug': None}, 'slug': None, 'tmdb': None, 'trakt': None}, 'year': None, 'title': None}}
  2. Wrong pagination info: headers have x-pagination-page-count: 156, but page 30 is already empty

This adds a workaround the first problem.

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of movie results with missing titles by skipping invalid entries.
    • Added warning logs when incomplete movie data is encountered.

@glensc glensc self-assigned this Jul 13, 2026
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 62f05e88-d722-432f-8e0b-59d285274cc0

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
trakt/users.py (1)

527-539: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add regression coverage for title-less movie entries.

Please test that invalid entries are skipped while valid entries still become Movie instances, including mixed valid/invalid payloads.

🤖 Prompt for 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.

In `@trakt/users.py` around lines 527 - 539, Add regression tests for the movie
parsing flow containing title-less entries: verify invalid entries are skipped,
valid entries are converted to Movie instances, and a mixed payload returns only
the valid movies. Anchor the tests to the parsing method containing the
movie_data title check.
🤖 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.

Nitpick comments:
In `@trakt/users.py`:
- Around line 527-539: Add regression tests for the movie parsing flow
containing title-less entries: verify invalid entries are skipped, valid entries
are converted to Movie instances, and a mixed payload returns only the valid
movies. Anchor the tests to the parsing method containing the movie_data title
check.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 14129542-0f65-4853-a278-86d27cd3de3a

📥 Commits

Reviewing files that changed from the base of the PR and between e490548 and 96780f1.

📒 Files selected for processing (1)
  • trakt/users.py
📜 Review details
🧰 Additional context used
📓 Path-based instructions (3)
trakt/users.py

📄 CodeRabbit inference engine (AGENTS.md)

When editing trakt/users.py, watch for nested model conversion and mixin-based attribute delegation.

Files:

  • trakt/users.py
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Match the surrounding file; keep local consistency instead of applying broad cleanup.
Import order should be stdlib, third-party, then local trakt.* imports; let isort handle ordering.
Preserve existing module docstrings and UTF-8 source headers in legacy files.
Avoid wholesale reflowing; keep line wrapping close to the nearby code.
Use single quotes where the file already does so.
Use type hints sparingly and locally; do not force a repo-wide typing migration.
Naming is conventional Python: snake_case for functions and variables, PascalCase for classes, UPPER_SNAKE_CASE for constants, and leading underscores for private helpers.
Public exports are often tracked with __all__; update it when the import surface changes on purpose.
Keep module and class docstrings short and factual.
The request layer uses generator-based decorators in trakt.decorators; preserve that pattern for new endpoints that fit the existing model.
For import-only changes, run pre-commit run isort --files <touched files> or an equivalent touched-files-only isort invocation.

Files:

  • trakt/users.py
trakt/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

trakt/**/*.py: Prefer absolute imports within the package, which is the dominant style here.
Raise ValueError for invalid user input and parameter validation.
Reserve RuntimeError for internal impossible states, not ordinary bad input.
Do not swallow exceptions unless the surrounding code already does that for compatibility.
Preserve the current BadResponseException behavior when JSON decoding fails.
Follow the existing HttpClient and TokenAuth patterns instead of adding a new request stack.
Many response objects are thin wrappers over API payloads; preserve fields that are already exposed.
Prefer explicit copying or filtering when normalizing JSON unless the current module intentionally mutates the input.
Keep list and collection classes iterable when the public API exposes them that way.
If you add new model properties, make sure they do not break existing __getattr__ delegation in mixins and dataclasses.
Keep public return types stable; tests generally assert classes, counts, and a few important field values.

Files:

  • trakt/users.py
🔇 Additional comments (1)
trakt/users.py (1)

4-4: LGTM!

Also applies to: 20-20

@glensc
glensc merged commit 9c06af3 into main Jul 13, 2026
8 checks passed
@glensc
glensc deleted the ignore-build-movies-errors branch July 13, 2026 11:43
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