-
Notifications
You must be signed in to change notification settings - Fork 493
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
| 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?
tomlm
left a comment
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
TranscriptMiddlewareLoggeralready, ensure that all cloned activities in logger have Ids, so that when logged intoMemoryTranscriptStore, eachItemalso has an Id.If an activity doesn't have an id,
MemoryTranscriptStorewill generate an Id for that activity/Itemfor the transcript storage, prefixing it with "g_" for "generated", as done in JS.Context
ContinuationTokenwithin the MemoryTranscriptStore.GetTranscriptActivitiesAsync relies on lastActivity.Idof loadedPagedResultPagedResult, we may end up infinitely loading the samePagedResultover 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 theTranscriptMiddlewareLoggerlayer.TestFlowis tightly coupled toTestAdapter(it requires an adapter of specifically typeTestAdapterinstead of an interface)