Skip to content

feat: Support restart and server-directed-shutdown-request in SSE contract test services - #82

Open
kinyoklion wants to merge 1 commit into
mainfrom
rlamb/service-capability-gaps
Open

kinyoklion wants to merge 1 commit into
mainfrom
rlamb/service-capability-gaps

Conversation

@kinyoklion

@kinyoklion kinyoklion commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

What

Updates both contract-test services (sync service.py/stream_entity.py and async async_service.py/async_stream_entity.py):

  1. server-directed-shutdown-request (newly advertised): the library halts on a 204 by default (http.py raises HTTPStatusError; the default error strategy fails on it), but the services overrode the error strategy to CONTINUE on everything, defeating it. The services now FAIL on HTTPStatusError with status 204 and CONTINUE otherwise (unchanged for all other errors).
  2. restart (newly advertised): the services returned 400 for the harness's restart command despite the client having interrupt(). The command now calls interrupt(), and the error that surfaces on the read path as a result is suppressed — the same precedent as okhttp's service suppressing StreamClosedByCallerException.

Why

A capability audit of the SSE contract-test services (write-up) found both features supported by the client but unwired/unadvertised in the service, so reconnection/caller can trigger a restart and HTTP behavior/204 halts re-connection attempts were silently skipping.

How verified

Ran the full sse-contract-tests harness locally against both services (linux/arm64, python 3.13): all released-suite tests pass, including both newly unlocked ones. (Two failures appear only against an unmerged audit-branch test group for two already-known python client issues — id-latching on data-less events and case-sensitive Content-Type matching — unrelated to this change.)

Draft for review of approach.

Opened from termag

SDK-3420


Note

Overview
Both sync and async SSE contract-test services now advertise restart and server-directed-shutdown-request, so the harness can run scenarios that were previously skipped.

Server-directed shutdown: Stream entities no longer treat every error as recoverable. Their custom ErrorStrategy still CONTINUEs on most failures, but FAILs when the error is an HTTPStatusError with status 204, matching the client’s default halt-on-204 behavior that the old “always continue” override blocked.

Restart: The harness restart command is handled by calling interrupt() on the active SSE client. The resulting read-path fault is suppressed once (via _suppress_next_fault) so it is not reported to the harness as an error, consistent with other SDK contract services.

Reviewed by Cursor Bugbot for commit 607b43d. Bugbot is set up for automated code reviews on this repo. Configure here.

Two capabilities the client already supports were not usable by the SSE
contract test suite, in both the sync and async test services:

- server-directed-shutdown-request: the library halts on a 204 by default,
  but the services' error_strategy override continued on every error,
  defeating it. The services now FAIL on HTTPStatusError with status 204
  and CONTINUE otherwise (as before).
- restart: the services returned 400 for the harness's restart command
  despite the client having interrupt(). The command now calls interrupt(),
  and the error that surfaces on the read path as a result is suppressed
  (same precedent as okhttp's service suppressing
  StreamClosedByCallerException).

Verified: full contract test suite passes against both services,
including the newly unlocked "204 halts re-connection attempts" and
"caller can trigger a restart" tests.

Generated-by: termag
@kinyoklion
kinyoklion marked this pull request as ready for review October 30, 2026 23:24
@kinyoklion
kinyoklion requested a review from a team as a code owner October 30, 2026 23:24

This branch has not been deployed

No deployments
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