Repository navigation
Conversation
The API can return a sentiment item with `"end": null` (e.g. when a word gets 0/0 timestamps), which makes `Transcript.get_by_id` fail to parse the whole transcript. Extend the existing `start` null workaround on `Word` to `end`, converting null to 0. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013m8gQdRBqzz5kme9fBgo63
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The API can return a
sentiment_analysis_resultsitem with"end": null(seen on a Universal-3.5 Pro transcript with speaker labels; same root cause as CSAT-447, where a word got 0/0 timestamps).Sentiment.endis typedint, soTranscript.get_by_idfails to parse the entire transcript:The SDK already works around the same problem for
start(CSAT-250) with abeforevalidator onWordthat converts null to0. This PR extends that validator toend, for both pydantic v1 and v2. Field types are unchanged (endstaysint), so this is non-breaking for callers.A matching API-side fix (stop returning null
end) is being done separately in the API repo.Changes
assemblyai/types.py:Word's null-to-0 validator now coversstartandend.tests/unit/test_sentiment_analysis.py: addtest_sentiment_analysis_null_end, mirroring the existingtest_sentiment_analysis_null_start.Testing
pytest tests/unit: 739 passed (the new test fails without the fix).ruff format --check/ruff checkwithruff.tomlclean onassemblyai/types.py.🤖 Generated with Claude Code
https://claude.ai/code/session_013m8gQdRBqzz5kme9fBgo63
Generated by Claude Code