-
Notifications
You must be signed in to change notification settings - Fork 479
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
Ensured all Activities stored in transcript have Ids #3701
Conversation
…vity() is returning
…lf overrides null Activity Ids
… activity with null id)
…le still assigning ids to inbound to TestFlow (the user messages) an id
@@ -134,7 +134,27 @@ public async Task OnTurnAsync(ITurnContext turnContext, NextDelegate nextTurn, C | |||
private static IActivity CloneActivity(IActivity activity) | |||
{ | |||
activity = JsonConvert.DeserializeObject<Activity>(JsonConvert.SerializeObject(activity, _jsonSettings)); | |||
return activity; | |||
var activityWithId = EnsureActivityHasId(activity); | |||
|
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.
Alternatively, you can just: return EnsureActivityHasId(activity);
{ | ||
var activityWithId = activity; | ||
|
||
if (activity == null) |
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.
Better to have the check for null before creating activityWithId
/// </summary> | ||
public class AllowNullIdTestAdapter : TestAdapter | ||
{ | ||
private bool _sendTraceActivity; |
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.
readonly?
private readonly object _conversationLock = new object(); | ||
private readonly object _activeQueueLock = new object(); | ||
private Queue<TaskCompletionSource<IActivity>> _queuedRequests = new Queue<TaskCompletionSource<IActivity>>(); | ||
private int _nextId = 0; |
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.
readonly?
/// </summary> | ||
/// <returns>The next activity in the queue; or null, if the queue is empty.</returns> | ||
/// <remarks>A <see cref="TestFlow"/> object calls this to get the next response from the bot.</remarks> | ||
public new IActivity GetNextReply() |
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.
This can be private.
/// </summary> | ||
/// <param name="cancellationToken">cancellation Token.</param> | ||
/// <returns>activity when it's available or canceled task if it is canceled.</returns> | ||
public new Task<IActivity> GetNextReplyAsync(CancellationToken cancellationToken = default) |
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.
Is this method used?
/// <returns>An appropriate message activity.</returns> | ||
/// <remarks>A <see cref="TestFlow"/> object calls this to get a message activity | ||
/// appropriate to the current conversation.</remarks> | ||
public new Activity MakeActivity(string text = null) |
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.
Can this be private?
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.
Well then... |
Fixes #3665
As, done in JS's
TranscriptMiddlewareLogger
already, ensure that all cloned activities in logger have Ids, so that when logged intoMemoryTranscriptStore
, eachItem
also has an Id.If an activity doesn't have an id,
MemoryTranscriptStore
will generate an Id for that activity/Item
for the transcript storage, prefixing it with "g_
" for "generated", as done in JS.Context
ContinuationToken
within the MemoryTranscriptStore.GetTranscriptActivitiesAsync relies on lastActivity.Id
of loadedPagedResult
PagedResult
, we may end up infinitely loading the samePagedResult
over and over again.Testing
In order to test that activities with null ids are assigned ids properly in transcript storage, I had to create a custom
TestAdapter
, since the one "off the shelf" automatically fills in an activity id, never allowing for null ids to pass through to theTranscriptMiddlewareLogger
layer.TestFlow
is tightly coupled toTestAdapter
(it requires an adapter of specifically typeTestAdapter
instead of an interface)