Skip to content

MPT-24897 Document truncation, retry and stub errors on stream() - #408

Merged
jentyk merged 3 commits into
mainfrom
bugfix/MPT-24897/stream-raises-list-omits-truncation-and-retry-errors
Sep 8, 2026
Merged

jentyk merged 3 commits into
mainfrom
bugfix/MPT-24897/stream-raises-list-omits-truncation-and-retry-errors

Conversation

@jentyk

@jentyk jentyk commented Sep 3, 2026 •

Copy link
Copy Markdown
Member

🤖 AI-generated PR — Please review carefully.

What

Fixes MPT-24897: the Raises section of both stream() docstrings listed the seven streaming errors plus JSONDecodeError and ValueError, but omitted three exceptions the same call tree raises:

  • MPTStreamingTruncatedError — raised by raise_stream_body_error when the connection aborts mid-body. This is the most likely runtime failure of a long export, and docs/streaming.md documents it prominently.
  • MPTMaxRetryError — raised by raise_stream_open_error when the transparent retry budget is exhausted while the response is still being opened.
  • TypeError — raised by DeletionStub.from_record on the yield path when a deletion stub arrives without a string id.

Neither MPT error is intercepted by the mixin's except MPTHttpError guard around the stream open: MPTStreamingTruncatedError extends MPTStreamingError and MPTMaxRetryError extends MPTError directly, so both escape that guard and reach the caller. A consumer writing exception handling from the docstring alone covers the listed errors but not these three, so a mid-body connection abort escapes their handler unclassified.

How

  • Added the three missing entries to the Raises section of both StreamingMixin.stream() and AsyncStreamingMixin.stream(), ordered by where each occurs on the wire: open-phase retry exhaustion first, mid-body truncation immediately before the end-of-body MPTStreamingIncompleteError it is easily confused with, and the stdlib errors last.
  • Wording reuses the existing sources — client.py, streaming_response.py, DeletionStub.from_record and docs/streaming.md — so the same failure is described the same way wherever it appears.
  • docs/streaming.md: the deletion-stub section stated that only id is guaranteed on a stub without saying what happens when that guarantee is violated, so it now notes the TypeError. The truncation and retry-exhaustion errors were already covered there, in both the error table and the timeout section, so those parts are unchanged.

Documentation only — no behaviour change, no public API change.

Testing

  • No new tests. The change adds no behaviour: every exception now listed was already raised by the existing call tree, and each is already covered by the tests for the module that raises it.
  • make check passes (ruff format, ruff check, flake8, mypy, uv lock --check).
  • make test passes: 2628 tests, 99% coverage.

🤖 Generated with Claude Code

  • Updated StreamingMixin.stream() and AsyncStreamingMixin.stream() docstrings.
  • Documented MPTMaxRetryError, MPTStreamingTruncatedError, and TypeError.
  • Updated docs/streaming.md for invalid deletion stubs.
  • No runtime behavior or public API changes.

The Raises section of both stream() docstrings omitted three exceptions
their own call tree raises: MPTStreamingTruncatedError for a connection
aborted mid-body, MPTMaxRetryError for retry exhaustion while opening
the response, and TypeError for a deletion stub without a string id.
Neither MPT error is caught by the mixin's except MPTHttpError guard,
so both reach the caller.

A consumer writing exception handling from the docstring alone would
miss them — most notably the truncation error, the likeliest runtime
failure of a long export — so list them ordered by where they occur on
the wire. Align docs/streaming.md, whose deletion-stub section stated
the id guarantee without saying that violating it raises TypeError.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@jentyk
jentyk requested a review from a team as a code owner September 3, 2026 19:10
@github-actions

github-actions Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Warnings
⚠️

This PR contains 3 commits.

Please squash them into a single commit to keep the git history clean and easy to follow.

Multiple commits are acceptable only in the following cases:

  1. One commit is a technical refactoring, and another introduces business logic changes.
  2. You are doing a complex multi-step refactoring (although in this case we still recommend splitting it into separate PRs).
⚠️

This PR contains 2 merge commit(s).
Please use git pull --rebase to keep a clean, linear history.

Offending commits:

  • 7cae6f4 — Merge branch 'main' into bugfix/MPT-24897/stream-raises-list-omits-truncation-and-retry-errors
  • 4beebce — Merge branch 'main' into bugfix/MPT-24897/stream-raises-list-omits-truncation-and-retry-errors

✅ Found Jira issue key in the title: MPT-24897

Generated by 🚫 dangerJS against 4beebce

@coderabbitai

coderabbitai Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Advanced

Run ID: 7d57dd44-6460-4152-804b-90e232e5ec8a

📥 Commits

Reviewing files that changed from the base of the PR and between c8e4788 and 4beebce.

📒 Files selected for processing (1)
  • docs/streaming.md
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • softwareone-platform/mpt-extension-skills (manual)
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/streaming.md

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The streaming API documentation now describes retry exhaustion, truncated response bodies, invalid deletion-stub identifiers, and linear assembly of records spanning multiple body chunks.

Changes

Streaming documentation

Layer / File(s) Summary
Document streaming behavior and errors
mpt_api_client/http/mixins/streaming_mixin.py, docs/streaming.md
The synchronous and asynchronous stream() documentation lists retry, truncation, and deletion-stub identifier errors. The guide documents string id validation for deletion stubs and linear assembly for multi-chunk records.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Merge Risk: ⚪ Minimal · up to 4beeb

Streaming documentation now describes existing retry, truncation, and invalid deletion-stub errors without changing runtime behavior. No merge-blocking risk is identified.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Documentation Up To Date ✅ Passed PASS. The PR-side diff changes only documentation: docs/streaming.md and the stream() docstrings in mpt_api_client/http/mixins/streaming_mixin.py. It adds the missing exception documentation and…

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

@jentyk
jentyk marked this pull request as draft September 7, 2026 08:23
@sonarqubecloud

sonarqubecloud Bot commented Sep 7, 2026

Copy link
Copy Markdown

@jentyk
jentyk marked this pull request as ready for review September 8, 2026 09:12
@jentyk
jentyk merged commit a853a3b into main Sep 8, 2026
6 checks passed
@jentyk
jentyk deleted the bugfix/MPT-24897/stream-raises-list-omits-truncation-and-retry-errors branch September 8, 2026 10:13
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.

2 participants