Skip to content

Keep waiting for a review through rate limits and unavailability - #2

Open
apoorvarohilla wants to merge 7 commits into
mainfrom
fix/wait-through-retryable-problems
Open

apoorvarohilla wants to merge 7 commits into
mainfrom
fix/wait-through-retryable-problems

Conversation

@apoorvarohilla

@apoorvarohilla apoorvarohilla commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Problem

wait_for_review raised the 429 or 503 that ended one read's retries, even when most of its timeout was left. A CI job waiting on a review failed on a brief rate limit or service restart instead of waiting.

Loopback reproduction (real sockets and real time, ProoflineClient; the tests below cover both clients):

Server behavior Wait timeout Before After
503 five times (Retry-After: 0), then the review is COMPLETED 300 s raised HTTP 503 after 4 requests, 0.0 s COMPLETED after 6 requests, 5.0 s
503 with Retry-After: 90 3 s raised HTTP 503 after 1 request, 0.0 s TIMED_OUT after 1 request, 3.0 s

The outcome also depended on the length of the header rather than on the wait's deadline. test_retry_after_is_bounded_by_wait_deadline pins that a 503 with Retry-After: 20 against a 10-second wait returns TIMED_OUT, and prooflinedev#12 describes TIMED_OUT as the only consistent outcome for a retryable problem in a wait. But Retry-After: 61 against a 300-second wait raised 503 immediately, because the transport refuses a single call's retry above 60 seconds and the wait re-raised that refusal.

Approach

A single call keeps its bounds: at most four attempts, never retried earlier than its Retry-After, and a Retry-After over 60 seconds is returned to the caller. Those are the right limits for one request. The wait is the part that has a longer budget, so the change is in the wait:

  • When a read ends with a retryable 429 or 503, wait_for_review treats it like an unfinished review. It holds the next read until the larger of its own poll interval and the problem's Retry-After has passed, sleeping toward it in steps of at most a minute and never past the deadline, and reads again. When the deadline passes it returns TIMED_OUT with the last review it read, as it already does for a review that is still running.
  • Every other problem (400, 401, 403, 404, 500, 502, ...) still ends the wait and raises, as before. So does an encoded or unreadable 429 or 503, which the transport refuses before its retry policy reads it.
  • The transport marks the 429 and 503 problems that pass through its retry policy as retryable and records their parsed Retry-After (retry_after, inf for more seconds than a float holds, None when absent or invalid) on the ProoflineError it raises. retry_delay is split into retry_after (parse) and the existing 60-second retry bound, with unchanged results. Callers of non-retried requests such as request_review can read the same value.

The README and the wait_for_review docstring describe the new behavior.

Verification

New tests in tests/test_http.py, all on both clients with the suite's fake Clock:

  • test_wait_keeps_polling_after_one_request_exhausts_its_retries (429, 503): five 503s then a completed review returns COMPLETED; the requests and sleeps are exactly four transport attempts, one five-second wait poll, and the final read.
  • test_wait_honors_a_retry_after_longer_than_one_request_retries: with Retry-After: 90 the second request arrives exactly 90 seconds after the first (completion is only offered then), slept as 60 + 30.
  • test_wait_holds_a_retry_after_too_long_for_a_float_until_its_deadline: a 400-digit Retry-After holds the wait to its deadline (TIMED_OUT, one request) instead of polling early.
  • test_wait_retries_a_rate_limit_without_a_problem_document: four HTML 503 pages, then a completed review, returns COMPLETED; the sleeps are exactly the transport's 1, 2, 4 and the wait's 5.
  • test_wait_sleeps_a_very_long_retry_after_in_bounded_steps: Retry-After: 100000 in a wait with timeout=1e12 sleeps exactly 100000 seconds in steps of at most 60, then completes.
  • test_wait_times_out_when_retry_after_outlasts_its_deadline: Retry-After: 90 in a 60-second wait sleeps to the deadline and returns TIMED_OUT.
  • test_wait_keeps_the_last_review_read_before_the_service_was_unavailable: a RUNNING read followed by 503s returns TIMED_OUT that still carries the RUNNING review, after exactly three reads and sleeps of 5, 60 + 30 (the Retry-After) and 5 (to the deadline).
  • test_wait_still_raises_problems_that_are_not_retryable (400, 401, 403, 404, 500, 502): one request, no sleep, the same status raised.
  • test_wait_raises_an_encoded_rate_limit_it_cannot_read (429, 503): a gzip-encoded problem still raises invalid-response after one request, and is not retryable.
  • test_a_rate_limit_problem_carries_its_retry_after (429, 503): retryable and retry_after on a retried GET and a non-retried POST; a 403 has neither.

Against main, 28 of these 40 cases fail: the 20 cases of the seven waiting tests each raise 429 or 503, and the 8 cases of the last two tests fail only because main has no retryable or retry_after (an encoded problem raises there too). The 12 non-retryable cases pass on both. The existing single-call tests (test_retry_count_is_bounded_for_rate_limit_and_provider_unavailable, test_long_retry_after_is_not_retried_early, the malformed Retry-After cases) pass unchanged.

python -m pytest -q               259 passed, 8 subtests passed
python -m ruff check .            All checks passed
python -m ruff format --check .   237 files already formatted
python -m mypy proofline scripts  Success: no issues found

scripts/check.py does not run on Windows (prooflinedev#87), so I ran its steps directly. On Windows, test_streaming_and_resolution_keep_deadline_outcomes_explicit[sync] fails intermittently on main as well (2 of 12 runs before this change); that is the clock-resolution issue prooflinedev#85 addresses.

Review feedback

I ran Proofline on the first commit in my fork. It reported four warnings, which came down to two issues, and I confirmed both:

  • An encoded or unreadable 429 or 503 is refused by the transport before its retry policy reads it, but the wait retried it by status alone. The wait now continues only for problems marked retryable; test_wait_raises_an_encoded_rate_limit_it_cannot_read did not raise on the first commit and does now.
  • With a very large timeout, the whole Retry-After went to time.sleep, which raises OverflowError near 1e10 seconds. The wait now sleeps toward the Retry-After in steps of at most a minute.

A second run on that commit raised five more warnings:

  • A Retry-After with more digits than a float holds parsed to inf and was discarded, so the wait polled early. Confirmed: it is now kept as inf and the wait holds until its deadline. A single call still refuses it, as before.
  • The docs called unreadable responses not retryable, while a fully received 503 without a problem document (an HTML page from a proxy) is retryable. Confirmed as wording: the behavior was intended and is now tested; the README and docstring say that only a response refused before its body is read, such as an encoded one, is not retryable. (Reported twice.)
  • The 90-second test did not prove when the second request arrived. Confirmed: it now offers completion only after 90 seconds and checks each request's time.
  • That the wait can sample the clock after its deadline check and call get_review with no time left. I disagree that this needs a change: limit_timeout refuses the request before anything is sent when no budget remains, and the wait returns TIMED_OUT, the same as the loop on main.

A third run raised three more, all confirmed:

  • A 429 or 503 body nested too deeply for the JSON decoder raises RecursionError out of problem parsing before it can be marked retryable (reported three times). Confirmed, but it applies to every error status on main, and Don't report caller errors as invalid API responses prooflinedev/sdk-python#75 already catches RecursionError there, so I left it to that PR; with both merged, such a 429 or 503 is retryable.
  • The docs did not mention that retry_after can be inf. They do now.
  • The HTML 503 test checked only the outcome. It now checks the exact sleeps, so it proves the wait held before the final read.

A fourth run raised three more. I fixed one and disagree with two:

  • The unavailable-then-TIMED_OUT test checked only the outcome, which an early exit would also return. Confirmed: it now checks every read and sleep.
  • That the async wait's new hold uses asyncio.sleep, which does not run under Trio. The wait's existing poll sleep and the transport's retry sleep on main already use asyncio.sleep, so a Trio wait already fails there for a RUNNING review; the hold follows that. Moving the client to anyio.sleep would be a separate change.
  • That the README promises retryable but the deadline check can raise first. When the wait's deadline passes during a retry, the transport raises its timeout error rather than the 429 or 503, so there is no rate-limit problem to mark; wait_for_review returns TIMED_OUT, as the same README sentence says.

Related

prooflinedev#75 handles problem bodies nested too deeply to decode (see above).

prooflinedev#85 changes the condition just above this one (which timeout ends a wait as TIMED_OUT); it still re-raises 429 and 503, so the two changes are independent and compose.

wait_for_review raised the 429 or 503 that ended one read's retries, even
with most of its timeout left: five brief 503s, or one Retry-After over 60
seconds, failed a 300-second wait. A Retry-After of 20 against a 10-second
wait already returned TIMED_OUT, so the outcome depended on the header's
length rather than on the wait's deadline.

The wait now treats such a problem like an unfinished review. It polls
again no sooner than the Retry-After, or its own backoff, and returns
TIMED_OUT when its deadline passes. Other problems still end the wait. A
single call keeps its four-attempt and 60-second bounds. ProoflineError
carries the parsed retry_after for a 429 or 503 so the wait can honor it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@prooflinedev prooflinedev 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.

Proofline has 2 new findings to review.

View full review in Proofline

Comment thread proofline/_transport.py
seconds its valid Retry-After asked for, and None otherwise.
"""

retry_after: float | None = None

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Warning · Review waits poll before Retry-After on encoded responses

Both transports reject encoded 429 and 503 responses before attaching Retry-After, but this change makes both waits retry those errors by status alone.

With enough time remaining, a first encoded response asking for 90 seconds can trigger another poll after five seconds.

Preserve Retry-After on encoding errors without reading the rejected body.

View finding in Proofline

Also at:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Still present in this version: Proofline found the issue again. Proofline's finding in this version: Retry documentation leaves malformed 429 and 503 bodies ambiguous. View review

Comment thread proofline/client.py Resolved

@prooflinedev prooflinedev 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.

Proofline has 2 more findings to review, 4 in this review run.

View full review in Proofline

Comment thread proofline/_transport.py Resolved
Comment thread proofline/_transport.py Resolved
Review feedback on the previous commit:

- Both transports raise an encoded or unreadable 429 or 503 before the
  retry policy reads it, and the wait retried those by status alone. Mark
  the problems that pass through the retry policy as retryable and
  continue the wait only for those, so an encoded or unreadable response
  still raises as it did before.
- A wait with a very large timeout passed the whole Retry-After to
  time.sleep, which overflows near 1e10 seconds. Hold the next read until
  the Retry-After passes and sleep toward it in steps of at most a minute.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@prooflinedev prooflinedev 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.

Proofline has 2 new findings to review.

View full review in Proofline

Comment thread proofline/_transport.py
Comment on lines 204 to +207
"""An invalid or longer Retry-After returns the problem without an early retry."""
if value is None:
return float(2**attempt)
delay = retry_after(value)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Warning · Review waits poll early when a valid Retry-After overflows

A valid decimal Retry-After that overflows float becomes None, so both waits fall back to their normal polling interval.

After a readable 429 or 503, either wait can poll again after five seconds instead of returning TIMED_OUT without another request.

Distinguish overflowing delays from missing or invalid headers and suppress polling until the wait deadline for overflowing delays.

View finding in Proofline

Also at:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Still present in this version: Proofline found the issue again. Proofline's finding in this version: Oversized Retry-After values expose undocumented infinity. View review

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Still present in this version: Proofline found the issue again. Proofline's finding in this version: A 429 or 503 can time out after its last chunk without retry metadata. View review

Comment thread proofline/client.py
sleep(min(held, 60, _transport.remaining() or 0))
continue
try:
last = self.get_review(organization_id, review_id)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Warning · An expiring retry hold can start a review read after the deadline

Both wait loops check the deadline before sampling the clock for the retry hold. If that sample is past both cutoffs, they call get_review with no time left.

The wait enters the review-read path instead of exiting immediately.

Use the same monotonic timestamp to check the deadline and the retry hold before polling.

Details

The built-in transports reject the expired read before network I/O. The specific retry-hold trigger was absent before this change because service errors ended the wait rather than setting a hold.

View finding in Proofline

Also at:

@prooflinedev prooflinedev 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.

Proofline has 1 more finding to review, 3 in this review run.

View full review in Proofline

Comment thread README.md Outdated
## Errors and refusals

A refused request raises `ProoflineError` with the server problem's `status`, `type`, `title` and `detail`. When a review request creates nothing, the error also carries `refusal`, whose `reason` names the setting to change, such as `NO_LINKED_ENVIRONMENT` or `ENVIRONMENT_NOT_READY`, and `repository_name`. `RunNowRefusal` names the type of `refusal`. A refusal that does not match the public contract keeps its status, `title` and `detail` with the type `urn:proofline:sdk:invalid-response` and no `refusal`. Any other status, such as the 402 a review request answers when credits cannot pay, is a plain problem with no `refusal`. The token is redacted from every text field, and `repr` and `str` show only the status.
A refused request raises `ProoflineError` with the server problem's `status`, `type`, `title` and `detail`. When a review request creates nothing, the error also carries `refusal`, whose `reason` names the setting to change, such as `NO_LINKED_ENVIRONMENT` or `ENVIRONMENT_NOT_READY`, and `repository_name`. `RunNowRefusal` names the type of `refusal`. A refusal that does not match the public contract keeps its status, `title` and `detail` with the type `urn:proofline:sdk:invalid-response` and no `refusal`. Any other status, such as the 402 a review request answers when credits cannot pay, is a plain problem with no `refusal`. A 429 or 503 problem the service sent is `retryable`, and its `retry_after` holds the seconds its valid `Retry-After` asked for, or `None`; an encoded or unreadable response is not retryable. `wait_for_review` does not end on a retryable problem: it polls again no sooner than that `Retry-After` and returns `TIMED_OUT` if its timeout passes first. The token is redacted from every text field, and `repr` and `str` show only the status.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Warning · Retry docs blur invalid problem JSON and unreadable HTTP bodies

The README says unreadable responses are not retryable without distinguishing a failed body read from invalid problem JSON. A fully read 429 or 503 can be retryable even without a valid problem document.

Callers may expect wait_for_review to raise when it instead keeps waiting.

Clarify that retryability requires reading the HTTP body successfully, not decoding a problem document.

View finding in Proofline

Also at:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Still present in this version: Proofline found the issue again. Proofline's finding in this version: Deeply nested 429 or 503 bodies abort review waits. View review

@prooflinedev prooflinedev 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.

Proofline has 1 more finding to review, 4 in this review run.

View full review in Proofline

Comment thread tests/test_http.py Resolved
Review feedback on the previous commit:

- A Retry-After with more digits than a float holds parsed to inf and was
  discarded, so the wait polled at its own interval. Keep it as inf: the
  wait holds until its deadline. retry_delay still refuses it for a single
  call, as before.
- The docs called unreadable responses not retryable, while a fully
  received 429 or 503 without a problem document is retryable. Say which:
  only one refused before its body is read, such as an encoded one.
- The Retry-After test now offers completion only after the asked-for 90
  seconds and checks when each request arrived.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@prooflinedev prooflinedev 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.

Proofline has 1 new finding to review.

View full review in Proofline

Comment thread README.md Outdated
## Errors and refusals

A refused request raises `ProoflineError` with the server problem's `status`, `type`, `title` and `detail`. When a review request creates nothing, the error also carries `refusal`, whose `reason` names the setting to change, such as `NO_LINKED_ENVIRONMENT` or `ENVIRONMENT_NOT_READY`, and `repository_name`. `RunNowRefusal` names the type of `refusal`. A refusal that does not match the public contract keeps its status, `title` and `detail` with the type `urn:proofline:sdk:invalid-response` and no `refusal`. Any other status, such as the 402 a review request answers when credits cannot pay, is a plain problem with no `refusal`. The token is redacted from every text field, and `repr` and `str` show only the status.
A refused request raises `ProoflineError` with the server problem's `status`, `type`, `title` and `detail`. When a review request creates nothing, the error also carries `refusal`, whose `reason` names the setting to change, such as `NO_LINKED_ENVIRONMENT` or `ENVIRONMENT_NOT_READY`, and `repository_name`. `RunNowRefusal` names the type of `refusal`. A refusal that does not match the public contract keeps its status, `title` and `detail` with the type `urn:proofline:sdk:invalid-response` and no `refusal`. Any other status, such as the 402 a review request answers when credits cannot pay, is a plain problem with no `refusal`. A 429 or 503 whose body the client received in full is `retryable`, even without a problem document, and its `retry_after` holds the seconds its valid `Retry-After` asked for, or `None`. A 429 or 503 the client refuses before reading its body, such as an encoded one, is not retryable. `wait_for_review` does not end on a retryable problem: it polls again no sooner than that `Retry-After` and returns `TIMED_OUT` if its timeout passes first. The token is redacted from every text field, and `repr` and `str` show only the status.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Warning · Fully received 429 or 503 can end review polling early

This change promises retries for fully received 429 and 503 responses, but deeply nested JSON can raise RecursionError before retry metadata is set.

Both clients can exit wait_for_review with a nonretryable invalid-response error while time remains.

Treat JSON decoding recursion failures as missing problem documents so the transport preserves the status and retry metadata.

Details

The parser already let this exception escape before this change; the documented retry guarantee is new.

View finding in Proofline

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Still present in this version: Proofline found the issue again. Proofline's finding in this version: A fully received 429 or 503 can still end the review wait. View review

Review feedback on the previous commit:

- A 429 or 503 body nested too deeply for the JSON decoder or redaction
  raised RecursionError out of problem parsing, before the transport could
  mark it retryable. Treat it like any body that is not a problem document.
- Document that retry_after is inf for more seconds than a float holds.
- The test of a rate limit without a problem document now checks the
  exact sleeps, so it proves the wait held before the final read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@prooflinedev prooflinedev 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.

Proofline has 1 new finding to review.

View full review in Proofline

Comment thread proofline/client.py
Comment on lines 969 to +972
while (_transport.remaining() or 0) > 0:
held = not_before - monotonic()
if held > 0:
# Sleep in bounded steps until the service's Retry-After passes.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Warning · Long Retry-After crashes review polling under Trio

The new retry hold calls asyncio.sleep after a fully read 429 or 503 with a Retry-After above 60 seconds. Trio has no running asyncio loop for that sleep.

The wait raises RuntimeError instead of polling again or returning TIMED_OUT.

Use anyio.sleep for the async retry hold.

Details

Before this change, the wait re-raised the HTTP error before reaching its asyncio-only polling sleep. This change reaches that sleeper even when the first read fails, provided time remains in the wait budget.

View finding in Proofline

@prooflinedev prooflinedev 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.

Proofline has 1 more finding to review, 2 in this review run.

View full review in Proofline

Comment thread tests/test_http.py
with Server(respond) as server:
async with session(mode, server.url) as client:
result = await call(client, "wait_for_review", ORG, REVIEW, timeout=100)
assert result.status == "TIMED_OUT"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Warning · Last-review test passes even if a 503 ends the wait early

The test checks only TIMED_OUT and the retained RUNNING review, both returned if the retryable 503 branch exits immediately after a successful poll.

A regression that skips the retry hold would pass in both client modes.

Assert that the fake clock reaches the deadline and verify the expected requests and sleep intervals.

View finding in Proofline

apoorvarohilla and others added 2 commits November 23, 2026 18:45
Review feedback: the test checked only the outcome, which an early exit
after the first unavailable read would also return. It now checks that
the wait held for the Retry-After and read again before its deadline.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
prooflinedev#75 already catches RecursionError where problem() decodes the body, so
this change no longer does. The HTML 503 test keeps its exact sleeps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@prooflinedev prooflinedev 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.

Proofline has 2 new findings to review. 5 open findings need attention in this pull request.

View full review in Proofline

Comment thread README.md Outdated
## Errors and refusals

A refused request raises `ProoflineError` with the server problem's `status`, `type`, `title` and `detail`. When a review request creates nothing, the error also carries `refusal`, whose `reason` names the setting to change, such as `NO_LINKED_ENVIRONMENT` or `ENVIRONMENT_NOT_READY`, and `repository_name`. `RunNowRefusal` names the type of `refusal`. A refusal that does not match the public contract keeps its status, `title` and `detail` with the type `urn:proofline:sdk:invalid-response` and no `refusal`. Any other status, such as the 402 a review request answers when credits cannot pay, is a plain problem with no `refusal`. The token is redacted from every text field, and `repr` and `str` show only the status.
A refused request raises `ProoflineError` with the server problem's `status`, `type`, `title` and `detail`. When a review request creates nothing, the error also carries `refusal`, whose `reason` names the setting to change, such as `NO_LINKED_ENVIRONMENT` or `ENVIRONMENT_NOT_READY`, and `repository_name`. `RunNowRefusal` names the type of `refusal`. A refusal that does not match the public contract keeps its status, `title` and `detail` with the type `urn:proofline:sdk:invalid-response` and no `refusal`. Any other status, such as the 402 a review request answers when credits cannot pay, is a plain problem with no `refusal`. A 429 or 503 whose body the client received in full is `retryable`, even without a problem document, and its `retry_after` holds the seconds its valid `Retry-After` asked for (`inf` for more seconds than a float holds), or `None`. A 429 or 503 the client refuses before reading its body, such as an encoded one, is not retryable. `wait_for_review` does not end on a retryable problem: it polls again no sooner than that `Retry-After` and returns `TIMED_OUT` if its timeout passes first. The token is redacted from every text field, and `repr` and `str` show only the status.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Warning · Receiving the full body does not guarantee retry metadata

The README and ProoflineError docstring promise retryability after full body receipt, but both transports can time out after yielding the last chunk, before attaching metadata.

Callers can receive a timeout instead of a retryable 429 or 503 with retry metadata.

Document that metadata is available only when the transport surfaces a 429 or 503 as a retryable ProoflineError.

View finding in Proofline

Also at:

  • proofline/_transport.py lines 87 to 91 · Fully received 429 and 503 bodies do not guarantee retry metadata · Retryability docs omit the final body-read deadline check

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Still present in this version: Proofline found the issue again. Proofline's finding in this version: A fully read 429 or 503 can still end review polling. View review

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@prooflinedev prooflinedev 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.

Proofline has 1 new finding to review.

View full review in Proofline

Comment thread README.md
Comment on lines 44 to +46
## Errors and refusals

A refused request raises `ProoflineError` with the server problem's `status`, `type`, `title` and `detail`. When a review request creates nothing, the error also carries `refusal`, whose `reason` names the setting to change, such as `NO_LINKED_ENVIRONMENT` or `ENVIRONMENT_NOT_READY`, and `repository_name`. `RunNowRefusal` names the type of `refusal`. A refusal that does not match the public contract keeps its status, `title` and `detail` with the type `urn:proofline:sdk:invalid-response` and no `refusal`. Any other status, such as the 402 a review request answers when credits cannot pay, is a plain problem with no `refusal`. The token is redacted from every text field, and `repr` and `str` show only the status.
A refused request raises `ProoflineError` with the server problem's `status`, `type`, `title` and `detail`. When a review request creates nothing, the error also carries `refusal`, whose `reason` names the setting to change, such as `NO_LINKED_ENVIRONMENT` or `ENVIRONMENT_NOT_READY`, and `repository_name`. `RunNowRefusal` names the type of `refusal`. A refusal that does not match the public contract keeps its status, `title` and `detail` with the type `urn:proofline:sdk:invalid-response` and no `refusal`. Any other status, such as the 402 a review request answers when credits cannot pay, is a plain problem with no `refusal`. A 429 or 503 that the client finishes reading within its deadline is `retryable`, even without a problem document, and its `retry_after` holds the seconds its valid `Retry-After` asked for (`inf` for more seconds than a float holds), or `None`. A 429 or 503 the client refuses before reading its body, such as an encoded one, is not retryable, and a deadline that passes first raises the timeout instead. `wait_for_review` does not end on a retryable problem: it polls again no sooner than that `Retry-After` and returns `TIMED_OUT` if its timeout passes first. The token is redacted from every text field, and `repr` and `str` show only the status.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Warning · MCP body-read deadlines surface as generic transport errors

The new README promises a timeout when a 429 or 503 body read misses its deadline, but MCP helpers wrap that read timeout as a generic transport error.

MCP callers receive urn:proofline:sdk:transport and cannot distinguish the deadline from other transport failures.

Map MCP timeouts separately or explicitly limit the README guarantee to REST calls.

View finding in Proofline

Also at:

@prooflinedev prooflinedev 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.

Proofline has 3 more findings to review, 4 in this review run. 9 open findings need attention in this pull request.

View full review in Proofline

Comment thread tests/test_http.py
with pytest.raises(ProoflineError) as raised:
await call(client, "rerun_review", ORG, REVIEW)
assert raised.value.retryable
assert raised.value.retry_after == 75

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Warning · Metadata test misses Retry-After loss after GET retries

The metadata test uses Retry-After: 75, above the 60-second cap, so the GET raises before exhausting its retries.

Dropping retry_after only on the final GET attempt leaves the metadata test green.

Use Retry-After: 0 in the retry-count test and assert retry_after == 0 on the error after four attempts.

Details

The existing retry-count test already catches an incorrectly retried POST with an in-cap header. Its GET case checks the status and attempt count, but not the retry metadata.

View finding in Proofline

Comment thread proofline/_transport.py
Comment on lines +87 to +90
the repository_name it refers to. A 429 or 503 read in full within the
deadline is retryable, even without a problem document, and retry_after
holds the seconds its valid Retry-After asked for (inf for more seconds
than a float holds), or None. A 429 or 503 refused before its body is

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Warning · Fully read 429 and 503 responses can lack retry metadata

The docstring promises retryability after a full read within the deadline, but deeply nested problem bodies can raise RecursionError before either transport attaches metadata.

Callers receive a generic invalid-response error without retry metadata.

Limit the documented guarantee to errors that reach the retry policy after problem parsing.

View finding in Proofline

Comment thread proofline/_transport.py
Comment on lines +87 to +90
the repository_name it refers to. A 429 or 503 read in full within the
deadline is retryable, even without a problem document, and retry_after
holds the seconds its valid Retry-After asked for (inf for more seconds
than a float holds), or None. A 429 or 503 refused before its body is

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Warning · Deeply nested error bodies suppress retry metadata

After reading a 429 or 503 within the deadline, both transports parse and redact the body before setting retry metadata, so RecursionError skips the new assignments.

Callers receive an invalid-response error instead of the HTTP status and retry metadata.

Catch RecursionError during decoding and redaction and use the status-preserving about:blank fallback.

Details

The parser could already raise before this change, but the base did not promise or expose retry metadata.

View finding in Proofline

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