Repository navigation
Release 0.8.17 review, rounds 2 and 3: outages at ERROR in every phase, widget timeout and network text, test gaps - #589
Merged
Conversation
It runs inside the handlers that report a failure, so an exception from it cut the stream with no error event, log line or metrics row. An error it cannot read is now unknown and the reason is logged. Also corrects the wording of three comments about the httpx fork the Anthropic SDK depends on, and the throttle reasoning in worth_retrying_now. Tested: tests/test_core/test_model_errors.py (new TestItNeverRaises cases).
A failure that surfaced as the stream was closed (GeneratorExit at the yield) started a second model call nobody would read. The retry helper now notes the close and re-raises. Also spells canceling the American way in a test name. Tested: new TestTheReaderClosesTheStream fails without the guard and passes with it.
…st both fail A check on the whole object has no field, so its line read "(: ..."; it now says "usage". Counts that also make the cost invalid are the provider's, so they log at WARNING, and only a cost-only failure (a price table defect) logs at ERROR. Tested: tests/test_api/test_reply_usage.py (TestWhatTheOperatorReads).
An outage before the response began, or a read that timed out, was a WARNING while the same outage mid-stream was an ERROR, so an alert on ERROR saw only some requests. Unavailable, connection and timeout failures from a provider are now ERROR (without a traceback unless a retry would have covered it); throttles and the caller's own refused key stay WARNING. Tested: tests/test_api/test_stream_failures.py asserts the level per phase.
The CLI and the widget printed any finite cost; a corrupt figure (1e305) filled the line. Both now treat a cost at or above one billion dollars as no cost. The CLI's print_error and print_warning also accept a message that is not a string. Tested: shared table row in tests/fixtures/usage_lines.json (Python and widget), print_error(None) in tests/test_cli/test_main.py.
AbortSignal.timeout aborts with a TimeoutError, not the AbortError the widget checked for, so a stalled request fell through to the generic failure text. Both names now read as the request timeout, streamed and not streamed. Tested: new block in frontend/test-widget-paced-streaming.js (287 checks pass).
Without the half-up step, 31 of the 3,000,001 whole micro-dollar values print differently, and none was in the shared table. Adds rows for three of them and for the edges at $0.0001, $0.01 and $1. Tested: Python and widget suites; mutants without the half-up step and with the under-$0.0001 edge moved fail both.
classify_model_error reads mid_stream from the error it found, not the wrapper; no test would have noticed the wrapper being read instead. Tested: the new case fails with the wrapper read and passes as written.
Tested: tests/test_api/test_reply_usage.py; the any-for-all mutant fails.
…lure tests - log level and traceback of a failure that was worth a retry but came too late or after a tool, and of an OpenRouter outage before the response - a community key's throttle is not called the reader's, and another failure on the reader's key is not called a throttle - the cancel log names the session - an Anthropic stream lost inside the SDK's own httpx is retried end to end - every streamed turn has a 60 s deadline so a retry loop fails instead of hanging, and the cancel tests poll for 30 s - botocore's backoff sleep is skipped (the file ran 29 s and now runs about 10 s; the requests are still made and counted) Tested: tests/test_api/test_stream_failures.py, 121 pass; each new assertion fails against a mutant of the code it guards.
Outage logging at ERROR in every phase, the widget's own request timeout, the CLI and cost hardening, the classifier that cannot raise, and the stream the reader closes. Docs only; the code and tests are in the commits before it.
Contributor
Preview Deployment
This preview will be updated automatically when you push new commits. |
…try a canceled task A failure that landed as the reader closed the stream was re-raised into a task nobody awaits, so the only trace was asyncio's "Task exception was never retrieved" with no request context; the helper now logs it with the endpoint, model, request and session. A task canceled while the model's stream is open can end in the stream's own failure in place of the CancelledError; the helper treated that as an ordinary failure and retried. It now checks the task's cancelling() count as well as the close. Tested: two new tests in TestTheReaderClosesTheStream; each fails without its guard.
… error once One unreadable link (a wrapper whose __str__ raises) aborted the walk, so a readable cause behind it (a throttle) came out unknown. A failure to say where a failure came from discarded a known kind. The handlers that each classify one failure also logged an unclassifiable one once each; it is now logged once per exception. Adds exception_text, str() with a placeholder, for the log lines that report a failure. Also states that the errors OpenRouter raises in a stream carry no status, instead of "never" marked. Tested: tests/test_core/test_model_errors.py; the dedupe and the per-link isolation each fail a test without them.
…ep a traceback The docstring's colon list named the cases that get a traceback but read as examples of the exception, omitted the caller's-key throttle wording, and ended in a ragged line; after_retry keeps the traceback rather than raising the level, and the comment above needs_traceback described the level. Comments only.
A __str__ that raises dropped the logging module's line (it prints "--- Logging error ---" and moves on), leaving the reader's error id matching nothing, and cut the stream in the ValueError branches that put str(e) in the message. The failure line and those messages now carry exception_text. Tested: new test in tests/test_api/test_stream_failures.py; fails with the raw error in the line.
data.get("message", default) keeps an explicit null, so the CLI printed "Error: None".
Also lets the error and warning printers take a message that is not a string.
Tested: two new stream tests in tests/test_cli/test_main.py; both fail with the old
fallback.
Tested: tests/test_cli (the config reset test reads the message).
The comment said Python's integer arithmetic could not take a larger cost, which is not so; the cutoff keeps the CLI and the widget printing the same digits. Comment only.
… languages Only a 1e305 row covered the cutoff, so moving it by one step passed. Rows for just under it and for exactly it. Tested: a <= mutant fails the Python and the widget suite.
…the browser Only a TypeError that mentions "fetch" was taken for a network failure, so Safari's "Load failed" and "The network connection was lost." and Chrome's "network error" (a body read cut short) reached the banner as the browsers worded them. A TypeError that matches the known wordings now reads "Network error. Please check your connection."; other TypeErrors and errors of other kinds keep their text. Also states in the timeout helper's comment only what is known: the widget aborts a request only by its own timeout. Tested: new block in frontend/test-widget-paced-streaming.js (295 checks pass); the old fetch-only check and a check that ignores the error's kind each fail it.
The earlier-warning sentence was wrong (an outage was always a warning before this release); what the widget shows for its own timeout is the banner, plus "Connection timeout" only on a reply that had text; the CLI's own 120 s timeout may win; a cost at or above one billion is dropped; the OpenRouter boundary of the retry; the null CLI message, the network wording and the cancel guard; the NWB origins are exact in the community's cors_origins while the worker admits the suffix. Docs only.
…e, tidy test text The Anthropic SDK depends on the published httpx2 package (anthropic 1.6.0 requires httpx2>=2.0), which the comments called a vendored copy or a fork. A 503 or 500 answer before the response is an error answer, not a refusal (a refusal is a 4xx the request caused). The OpenRouter 5xx test said the client's own retries cover it, which its own request count contradicts; the redundant 30 s wait_for in one test goes, since every streamed turn has a deadline. Comments, test names and ids only. Tested: the four touched test files, 246 pass.
The "Retrying ..." warning put the raw error in the log line, so an error whose __str__ raises dropped it (and, under a handler that raises, ended the stream instead of retrying). It now uses exception_text, as the failure line does. Also drops a check in the outage test that the kinds it names already imply. Tested: new test in the next commit.
- botocore's retry of a refused request is asserted to exist, not only to equal itself - a connection that could not be made is an outage (ERROR) - a second failure of another kind after a retry is an ERROR with its traceback - the retry line and the ValueError branches survive an error that cannot print - the CLI's null message fallback for all four stream paths - a failure the classifier can name but not place keeps its kind and is not retried - the widget's network wording is anchored - the close stand-in's docstring says what it is for Tested: each new test fails against a mutant of the code it guards; 455 pass in the touched Python files and 296 widget checks pass.
10 tasks
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.
Fixes from rounds 2 and 3 of the release review of #585 (four reviewers each round: code, error handling, tests, comments, on the Sonnet model), applied before the release.
Refs #578, #582, #587.
Round 2 checked each round 1 fix (#588) and looked for what the fixes introduced; round 3 did the same for round 2's.
No critical or high findings in either round; every finding is below, fixed or answered.
Round 2: what the review found, and what changed
Round 1 made a stream cut short an ERROR but left the same outage at WARNING when it came as a 503 before the response, or as a read that timed out, so an alert on ERROR saw only some of an outage's requests.
A provider's unavailable, connection and timeout failures now log at ERROR in every phase of the call, with the traceback only where a retry would have covered it.
Throttles and the caller's own refused key stay WARNING.
A failure that surfaced as the reader closed the stream (GeneratorExit at the yield) started a second model call that nobody would read; the helper now notes the close and re-raises.
classify_model_errorcould raise inside the handlers that report a failure, which would cut the stream with noerrorevent, log line or metrics row.It now returns "unknown" and logs why.
AbortSignal.timeoutaborts with aTimeoutError, not anAbortError, so a stalled request showed the browser's own text in the banner.Round 3: what the review found, and what changed
The helper now logs it with the endpoint, model, request and session.
The stream's own failure can replace the
CancelledError, which the helper then treated as an ordinary failure; it now checks the task'scancelling()count too.(Under Starlette's cancel scopes the retry's
sleepwould have raised it again, so production was safe; a plaintask.cancel()was not.)TypeErrorwith a known network wording now reads "Network error. Please check your connection."Other
TypeErrors, and errors of other kinds, keep their text.The failure line, the retry line and those messages now use
exception_text._stream_failure_eventdocstring contradicted itself (the list after the colon were the cases that do get a traceback),after_retry's and theneeds_tracebackcomments described the wrong effect, and the cost cutoff's comment gave the wrong reason; all corrected.It also now says a model served through OpenRouter gets no retry, and that the NWB origins are exact in the community's
cors_originswhile the worker admits the suffix.httpx2is called a separate package in five comments that called it vendored or a fork; the 503 tests are "error answer" tests, not "refusal" tests; a check in the outage line that its kinds already imply is gone.exception_textsites, the CLI fallback on all four stream paths, a failure the classifier can name but not place, and the widget's anchored network wording.Not changed, and why
_arrived_mid_stream(three mutants no test can tell apart, since classification screens the same errors first): the function is meant to be right on its own, and a later change to the classifier should not silently make a failure look mid-stream.error.name === 'AbortError'check next toAbortSignal.timeout(workers/osa-worker/index.js): it has the same shape as the widget's bug, but itserror.message.includes('timeout')fallback is expected to catch the case (not verified), and the worker is outside this release's changes.frontend/test-widget-paced-streaming.js"the reader saw the reply grow through N different lengths" failed once in six runs under 56 busy processes on this machine; it is on develop already and unrelated to this branch.Testing
The Python suites (
tests/test_api,test_metrics,test_cli,test_core,test_frontend) and all 23 widget suites pass.That run leaves out
test_chat_resume_endpoint.py: 19 of its 21 tests fail with 401 identically on a clean develop here (they did before this branch).Each new assertion was shown to fail against a mutant of the code it guards.