fix(apps): specify specific string for 'Content stream is not allowed'#500
Merged
Conversation
…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>
Contributor
There was a problem hiding this comment.
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._sendso the “already completed streamed message” variant no longer matches the"not allowed"→StreamNotAllowedErrorbranch. - 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. |
heyitsaamir
approved these changes
Jul 8, 2026
heyitsaamir
left a comment
Collaborator
There was a problem hiding this comment.
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)
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.
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 →StreamNotAllowedErrorbut it also caught:
Content stream is not allowed on an already completed streamed message— the stream is already finalized → terminal, should beTerminalStreamError.This latter error isn't possible given our current implementation, so we don't need to specially handle this case