Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Semantics of constrained blob streams for the server #1389

Open
david-perez opened this issue Sep 7, 2022 · 0 comments
Open

Semantics of constrained blob streams for the server #1389

david-perez opened this issue Sep 7, 2022 · 0 comments
Labels
documentation This is a problem with documentation. guidance Question that needs advice or information.

Comments

@david-perez
Copy link
Contributor

What should a server do upon receiving a streaming blob that does not satisfy the modeled constraint traits?

Currently, the only allowed constraint trait on the blob shape is the length trait.

When the blob is non-streaming, the server framework can buffer the entire request body in memory, check the length, and only then hand the blob to the application code. This is what smithy-rs does in this case.

However, when the blob is streaming, the intention is that the application code can begin working with the stream of bytes as they come in, processing the stream chunk by chunk. For example, smithy-rs hands the application code a aws_smithy_http::byte_stream::ByteStream, a type that implements the Stream trait, that users can lazily poll for chunks of Bytes.

So, how should a server enforce a length constraint trait on the streaming blob?

  1. Should it keep track of how many bytes the application code has polled, and error out the moment it attempts to poll past the length.max value?
  2. How do we enforce length.min?

Bear in mind that application code is free to poll the stream however much they need. That is, it's perfectly valid for application code to poll n bytes (and possibly start rendering a response!) and ignore (or not) the rest. Perhaps n is not within the modeled length bounds, but the full blob stream the client sent is.

@milesziemer milesziemer added the guidance Question that needs advice or information. label Sep 13, 2022
@kstich kstich added the documentation This is a problem with documentation. label Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation This is a problem with documentation. guidance Question that needs advice or information.
Projects
None yet
Development

No branches or pull requests

3 participants