-
Notifications
You must be signed in to change notification settings - Fork 281
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
fix: parse attachments from streaming request #3888
Conversation
Pull Request Test Coverage Report for Build 1082891443
💛 - Coveralls |
|
||
const activity = await activityStream.readAsJson<Activity>(); | ||
|
||
activity.attachments = await Promise.all( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably are aware of this, but adding this note just in case -- attachments have a content type, and depending on that content type they could be json, cards, audio, text, etc. Another dimension is whether the attachment is inlined or has a url. I'd suggest to try this out with a few different contents and mechanism combinations to make sure we are covering the scenario families.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you know for a fact that this code is independent of any corner case combination then that's fine. In C# there are 2 families of attachments to test to cover pretty much all cases, I'm just not sure what the minimum test base is for this code without spending a bit more time on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not expert on this topic, you can refer to how C# SDK works.
FYI, someone told me, stream could be never-ending, e.g. a speech stream. That means await Promise.all()
could (almost) never resolve.
Maybe we didn't go as far as this yet even in C#.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@compulim, the IReceiveRequest
, in this context, is a discrete set of bytes from a socket. The socket, itself, is a stream that is never-ending.
@carlosscastro working on verifying now, thanks for the pointers! I think I have found another hiccup when adding contentType
-aware stream reading.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@compulim good point! the endless stream could exist in the highest protocol layer, which assembles streams. However, this is a requirement that was part of the original design but it's not completely implemented, and we don't really use it for any practical scenario and many parts of the code don't really support that.
@carlosscastro I've fixed the content type issue in the latest commit, please have a look and see if you agree with the changes. I verified that attachments coming in via DL ASE now appear well-formed (i.e. I'm getting a content type and either a JSON-parsed object for application/json or a string of chars otherwise). |
libraries/botframework-streaming/src/assemblers/payloadAssembler.ts
Outdated
Show resolved
Hide resolved
1b1cb39
to
c8b1b60
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nits around unused imports, otherwise it looks good!
77e3125
to
286e25d
Compare
Fixes #3887