Fix missing signed empty end frame on event stream close#691
Conversation
|
Just curious: with this change applied, are we able to modify some existing integration tests to remove |
|
Approved. However, there are some other issues when I test this with the Transcribe Streaming integration tests and the simple_file.py example. The end frame fix resolves the "complete signal was sent without the preceding empty frame" error, but the |
134559e to
8a357d1
Compare
| return | ||
| self._closed = True | ||
|
|
||
| # Send a signed empty frame to signal stream completion. |
There was a problem hiding this comment.
Could we wrap the signed-empty-frame write in a try/finally so the writer is always closed?
It may also be worth making the test assert that the writer is closed, or using AsyncBytesProvider to decode the written frame and verify the terminator payload is actually empty.
| return | ||
| self._closed = True | ||
|
|
||
| # Send a signed empty frame to signal stream completion. |
There was a problem hiding this comment.
Do you know if this is safe for even non-bidirectional APIs?
There was a problem hiding this comment.
I just realized all AWS operations that use input streaming are also bi-directional
There was a problem hiding this comment.
Yep, thanks for confirming! Also worth noting the Java SDK sends the trailing empty frame unconditionally for all signed event streams, no bidi check, so this appears to be part of the SigV4 protocol itself rather than a bidi-specific behavior.
Issue #, if available:
awslabs/aws-sdk-python#46
Description of changes:
Fix
AWSEventPublisher.close()to send a signed empty end frame to signal stream completion.SigV4 signed event streams require a final signed empty message before the HTTP body stream closes. This fix:
sign_empty()method to theEventSignerprotocol insmithy-core.AWSEventPublisher.close()to callsign_empty()when sending the termination frame insmithy-aws-event-stream.This eliminates the following errors:
BadRequestException: A complete signal was sent without the preceding empty frame.ValidationException: Invalid input request, please fix your input and try again.Related PR: #692
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.