FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Align TranscriptLoggerMiddleware implementation with C# version by matthiasblaesing · Pull Request #141 · microsoft/botbuilder-java · GitHub

This repository was archived by the owner on Dec 4, 2023. It is now read-only.
/ botbuilder-java Public archive

Align TranscriptLoggerMiddleware implementation with C# version - #141

Closed
Matthias Bläsing (matthiasblaesing) wants to merge 1 commit into
microsoft:masterfrom
matthiasblaesing:transcript-middleware-azure2
Closed

Align TranscriptLoggerMiddleware implementation with C# version#141
Matthias Bläsing (matthiasblaesing) wants to merge 1 commit into
microsoft:masterfrom
matthiasblaesing:transcript-middleware-azure2

Conversation

Matthias Bläsing (matthiasblaesing) commented Nov 1, 2019
edited
Loading

Copy link
Copy Markdown
Contributor

The TranscriptLoggerMiddleware works on the Emulator, but fails when run
on Azure Infrastructure. This is caused by the invalid modification of
the incoming Activity.

The modifications then create invalid data leading to this JSON fragment
for reply activities:

{
    // ...
    "recipient":{
        "properties":{
            "role":{}
        },
        "id":"8d51e790-8bd3-4450-af3d-1741838d1354",
        "role":{}
    },
    // ...
}

The role properties should be set to a string, not an object. This
results in a
http 400 status from the bot framework:

{
  "error": {
    "code": "BadSyntax",
    "message": "Invalid or missing Activity in request"
  }
}

The TranscriptLoggerMiddleware works on the Emulator, but fails when run
on Azure Infrastructure. This is caused by the invalid modification of
the incoming Activity.

The modifications then create invalid data leading to this JSON fragment
for reply activities:

{
    // ...
    "recipient":{
        "properties":{
            "role":{}
        },
        "id":"8d51e790-8bd3-4450-af3d-1741838d1354",
        "role":{}
    },
    // ...
}

The role properties should be set to a string, not an object. This
results in a
http 400 status from the bot framework:

{
  "error": {
    "code": "BadSyntax",
    "message": "Invalid or missing Activity in request"
  }
}

Copy link
Copy Markdown
Contributor Author

tracyboehrer (@tracyboehrer) this is an alternative implementation to #139 . The intention is to keep the change minimal, but still make it compatible with the azure backend. I had a look at the C# implementation and this is in my view the same approach as taken there.

Copy link
Copy Markdown
Member

Matthias Bläsing (@matthiasblaesing) I compared to the Python impl, and your original technique of setting the Role on the From ChannelAccount appears to be correct as well. That version was taken from JavaScript.

Python

if activity:
    if not activity.from_property.role:
        activity.from_property.role = "user"
    self.log_activity(transcript, copy.copy(activity))

JS

if (context.activity) {
    if (!context.activity.from.role) {
        context.activity.from.role = "user";
    }

    this.logActivity(transcript, this.cloneActivity(context.activity));
}

This is all some fairly old code. My hunch is that "role" wasn't originally defined, and came in through the overflow "properties" member on ChannelAccount. Still a bug that Java was using an ObjectNode though.

With that said, I'm having a conversation with the architects. The initial feedback was that a more recent strategy was not to mutate an incoming Activity. Though I would bet there are still places it's being done.

I should hear back shortly.

Copy link
Copy Markdown
Member

Closing in favor of original PR

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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL