Skip to content

fix(pixel): guard task group exception groups during stream revocation cleanup - #5600

Open
vaibhavsrv wants to merge 1 commit into
Osmantic:public-betafrom
vaibhavsrv:fix/pixel-stream-revocation-cleanup
Open

vaibhavsrv wants to merge 1 commit into
Osmantic:public-betafrom
vaibhavsrv:fix/pixel-stream-revocation-cleanup

Conversation

@vaibhavsrv

Copy link
Copy Markdown
Contributor

Why this matters

In the Pixel inference perimeter service (ods/extensions/services/pixel-inference/app/main.py), in-flight streaming generations are monitored concurrently by a credential watcher task in _guarded(). When a token is revoked during active streaming, the watcher completes with a ShareError("credential_no_longer_valid"), prompting _guarded() to cancel the active Starlette StreamingResponse.__call__ task (work) during cleanup. On Python 3.11+, cancelling Starlette's AnyIO task group causes await work to raise an ExceptionGroup containing task group cancellation and child exceptions. Because _guarded() only suppressed asyncio.CancelledError, this unhandled ExceptionGroup escaped the finally block, clobbering the intended ShareError and raising an unhandled task group exception instead of cleanly notifying the caller of credential invalidation.

This change conditionally includes BaseExceptionGroup in the suppression tuple when available on Python 3.11+ runtimes, ensuring that task group cancellation during stream revocation cleanup is safely suppressed while preserving the primary watcher ShareError for clean propagation. Existing stream timeouts, response bounds, and authorization precedence remain strictly untouched.

Validation

  • Baseline reproduction: pytest ods/extensions/services/pixel-inference/tests/test_inference_sharing.py -k test_stream_revocation_terminates_and_closes fails with an unhandled ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception: ShareError('credential_no_longer_valid')) escaping _guarded().
  • Post-fix verification: The revoked stream cleanly raises gateway.ShareError("credential_no_longer_valid") and closes the underlying transport socket with exit code 0.
  • Telemetry statement: "Pixel inference suites: 42 passed (41 isolated inference tests + 1 new standalone regression test). New-test py_compile, syntax, and diff checks pass; new regressions wired into Linux CI."

Overlap check

Risk / AI disclosure

AI-assisted investigation, implementation and CLI regressions. This strengthens ASGI task group cancellation suppression during stream revocation cleanup, not runtime admission. Independent human review and platform/runtime qualification remain gates. No running configuration, deployment or upstream merge changed.

Follow-up integration evidence

Composed with #5579 at 4fa6ad1 without conflicts. Production and test diffs passed together; adjacent pixel inference deadline and sharing contracts remain intact.
Backlog composition was local-only (production/test diffs, excluding workflow/Makefile wiring); it is not an upstream merge or independent human approval. Declared live-review gates remain open.

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