Standardize JSON converter failures - #8
Conversation
Model: GPT-5 Thread-ID: 019f6174-a2d2-7842-b89e-9919c04a63ac
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 52 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces a new InvalidJsonError exception and updates the JSON-to-JSON converter to raise it when encountering invalid JSON or non-spec schemas, replacing silent skips and generic decode errors. It also adds robust type validation for the input JSON structure and updates the test suite accordingly. The review feedback suggests strengthening the schema validation further by ensuring all elements within the segments list are dictionaries, and adding a corresponding test case to verify this behavior.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if ( | ||
| not isinstance(data, dict) | ||
| or not isinstance(data.get("version"), str) | ||
| or not isinstance(data.get("segments"), list) | ||
| ): |
There was a problem hiding this comment.
While the current check ensures that segments is a list, it does not verify that the elements within the list are dictionaries. If segments contains non-dictionary elements (e.g., strings or numbers), downstream consumers expecting the standard PodcastIndex segment structure (with keys like startTime and body) will raise a TypeError when attempting to access them.
Consider adding a check to ensure all elements in segments are dictionaries.
| if ( | |
| not isinstance(data, dict) | |
| or not isinstance(data.get("version"), str) | |
| or not isinstance(data.get("segments"), list) | |
| ): | |
| if ( | |
| not isinstance(data, dict) | |
| or not isinstance(data.get("version"), str) | |
| or not isinstance(data.get("segments"), list) | |
| or not all(isinstance(segment, dict) for segment in data["segments"]) | |
| ): |
| @pytest.mark.parametrize( | ||
| "data", | ||
| [ | ||
| [], | ||
| {"version": 1, "segments": []}, | ||
| {"version": "1.0.0", "segments": {}}, | ||
| ], | ||
| ) |
There was a problem hiding this comment.
To accompany the added validation for segment element types, consider adding a test case with non-dictionary elements in the segments list to verify it is correctly rejected.
@pytest.mark.parametrize(
"data",
[
[],
{"version": 1, "segments": []},
{"version": "1.0.0", "segments": {}},
{"version": "1.0.0", "segments": ["invalid"]},
],
)
Summary
InvalidJsonErrorconsistent with the other source-format convertersfailedinstead of reporting a nonexistent output as convertedRoot cause
json_file_to_json_filelogged and returned when required transcript fields were missing. Because returning normally signaled success,bulk_convertadded the input tosummary.convertedeven though no destination file had been written. Malformed JSON also exposed a lower-levelJSONDecodeErrorinstead of the converter-specific error contract used by other formats.Impact
Callers now receive one stable JSON conversion error for malformed or schema-invalid inputs, and bulk conversion summaries accurately report those files as failures.
Validation
uv run ruff check .uv run ruff format --check .uv run ty check podcast_transcript_convertuv run pyrefly checkuv run pytest -q— 109 passed