Skip to content

fix(apps): specify specific string for 'Content stream is not allowed'#500

Merged
lilyydu merged 3 commits into
mainfrom
lilyydu/http-stream-completed-error
Jul 9, 2026
Merged

fix(apps): specify specific string for 'Content stream is not allowed'#500
lilyydu merged 3 commits into
mainfrom
lilyydu/http-stream-completed-error

Conversation

@lilyydu

@lilyydu lilyydu commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Problem

Our streaming error conditions checks strings for keywords - but two of the errors share "not allowed". The one we want to catch is

  • Content stream is not allowed — the streaming feature is disabled for the user/bot → StreamNotAllowedError

but it also caught:

  • Content stream is not allowed on an already completed streamed message — the stream is already finalized → terminal, should be TerminalStreamError.

This latter error isn't possible given our current implementation, so we don't need to specially handle this case

lilyydu and others added 2 commits July 8, 2026 14:49
…reamError

The 'Content stream is not allowed on an already completed streamed
message' 403 shares the ContentStreamNotAllowed error code and the
'not allowed' substring with the generic stream-not-allowed error, so
it was incorrectly mapped to StreamNotAllowedError. Guard the 'not
allowed' branch against 'completed streamed message' so this terminal
case falls through to TerminalStreamError.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
pytest.raises(expected) also matches subclasses, so the 'already
completed streamed message' case passed even when StreamNotAllowedError
(a subclass of TerminalStreamError) was wrongly raised. Assert
type(exc_info.value) is expected so the test actually validates the
403 classification fix.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 8, 2026 22:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes HTTP 403 streaming error classification in the Apps package so that Teams’ "Content stream is not allowed on an already completed streamed message" is treated as a terminal (finalized) streaming error rather than a “streaming not allowed for user/bot” error.

Changes:

  • Tightened the 403 message parsing in HttpStream._send so the “already completed streamed message” variant no longer matches the "not allowed"StreamNotAllowedError branch.
  • Strengthened the parametrized 403 mapping test to assert the exact exception type (not a subclass), ensuring misclassifications are caught.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/apps/src/microsoft_teams/apps/http_stream.py Adds a guard to prevent misclassifying the “already completed streamed message” 403 as StreamNotAllowedError, allowing it to map to TerminalStreamError.
packages/apps/tests/test_http_stream.py Updates the 403 mapping test to assert the exact raised exception type, making the classification test effective.

@lilyydu lilyydu changed the title fix(apps): classify 'already completed streamed message' 403 as TerminalStreamError fix(apps): specify specific string for 'Content stream is not allowed' Jul 8, 2026

@heyitsaamir heyitsaamir left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not a huge fan of this string matching error checking. Let's chat with backend team to see if we can have another signal (or we can use exact string matching instead)

@lilyydu lilyydu merged commit 71babaa into main Jul 9, 2026
8 checks passed
@lilyydu lilyydu deleted the lilyydu/http-stream-completed-error branch July 9, 2026 16:01
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.

3 participants