Skip to content

Standardize JSON converter failures - #8

Merged
hbmartin merged 1 commit into
mainfrom
codex/json-standardization
Jul 14, 2026
Merged

Standardize JSON converter failures#8
hbmartin merged 1 commit into
mainfrom
codex/json-standardization

Conversation

@hbmartin

@hbmartin hbmartin commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • add an InvalidJsonError consistent with the other source-format converters
  • raise it for malformed JSON and invalid PodcastIndex transcript shapes, with source-path context
  • ensure bulk conversion records invalid JSON under failed instead of reporting a nonexistent output as converted
  • add direct, schema-type, error-contract, and bulk-conversion regression coverage

Root cause

json_file_to_json_file logged and returned when required transcript fields were missing. Because returning normally signaled success, bulk_convert added the input to summary.converted even though no destination file had been written. Malformed JSON also exposed a lower-level JSONDecodeError instead 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_convert
  • uv run pyrefly check
  • uv run pytest -q — 109 passed

Review in cubic

Model: GPT-5

Thread-ID: 019f6174-a2d2-7842-b89e-9919c04a63ac
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 52 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: c7dda5e6-97fe-4005-8aae-7647ff01c7ba

📥 Commits

Reviewing files that changed from the base of the PR and between 9220603 and c24beeb.

📒 Files selected for processing (5)
  • podcast_transcript_convert/converters/json_to_json.py
  • podcast_transcript_convert/errors.py
  • tests/test_convert.py
  • tests/test_errors.py
  • tests/test_json.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/json-standardization

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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment on lines +20 to +24
if (
not isinstance(data, dict)
or not isinstance(data.get("version"), str)
or not isinstance(data.get("segments"), list)
):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

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.

Suggested change
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"])
):

Comment thread tests/test_json.py
Comment on lines +63 to +70
@pytest.mark.parametrize(
"data",
[
[],
{"version": 1, "segments": []},
{"version": "1.0.0", "segments": {}},
],
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

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"]},
    ],
)

@hbmartin
hbmartin merged commit 344e2a6 into main Jul 14, 2026
7 of 8 checks passed
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