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

fix: parse attachments from streaming request #3888

Merged
merged 4 commits into from
Aug 2, 2021

Conversation

joshgummersall
Copy link
Contributor

Fixes #3887

@joshgummersall joshgummersall requested a review from stevengum July 28, 2021 01:17
@joshgummersall joshgummersall requested a review from a team as a code owner July 28, 2021 01:17
@coveralls
Copy link

coveralls commented Jul 28, 2021

Pull Request Test Coverage Report for Build 1082891443

  • 14 of 25 (56.0%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.03%) to 84.455%

Changes Missing Coverage Covered Lines Changed/Added Lines %
libraries/botbuilder/src/botFrameworkAdapter.ts 4 8 50.0%
libraries/botbuilder/src/cloudAdapter.ts 0 7 0.0%
Totals Coverage Status
Change from base Build 1082884211: -0.03%
Covered Lines: 19574
Relevant Lines: 21949

💛 - Coveralls


const activity = await activityStream.readAsJson<Activity>();

activity.attachments = await Promise.all(
Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor

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#.

Copy link
Contributor Author

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.

Copy link
Member

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.

@joshgummersall
Copy link
Contributor Author

@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).

@joshgummersall joshgummersall force-pushed the jpg/fix-streaming-attachments branch 3 times, most recently from 1b1cb39 to c8b1b60 Compare July 29, 2021 23:21
Copy link
Member

@stevengum stevengum left a 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!

libraries/botbuilder/src/cloudAdapter.ts Outdated Show resolved Hide resolved
libraries/botbuilder/src/botFrameworkAdapter.ts Outdated Show resolved Hide resolved
@joshgummersall joshgummersall force-pushed the jpg/fix-streaming-attachments branch from 77e3125 to 286e25d Compare July 30, 2021 16:25
@joshgummersall joshgummersall merged commit fe1757a into main Aug 2, 2021
@joshgummersall joshgummersall deleted the jpg/fix-streaming-attachments branch August 2, 2021 15:37
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.

Attachments is undefined when using Direct Line App Service Extensions
5 participants