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

BlobStorage is not tracking changes in state causing outdated state to be saved #6584

Closed
MathieuMarchant opened this issue Jan 27, 2023 · 2 comments · Fixed by #6585
Closed
Assignees
Labels
Bot Services Required for internal Azure reporting. Do not delete. Do not change color. bug Indicates an unexpected problem or an unintended behavior. customer-replied-to Indicates that the team has replied to the issue reported by the customer. Do not delete. customer-reported Issue is created by anyone that is not a collaborator in the repository.

Comments

@MathieuMarchant
Copy link

Version

4.19.1

Describe the bug

Looking at the documentation and samples, the way to update state is:

  • to create a property accessor from the state
  • fetch object from state with this accessor
  • update properties of the object
  • save changes on the state

Example code in the StateManagementBot

When doing so with MemoryStorage, everything works as expected.

When using Blob Storage, the initial state is written to the storage.
However when retrieving the object and updating it, on SaveChangesAsync the updated object is not correctly written.
Even when using the force:true the state is updated, but with the original version of the object, instead of the updated object.

To Reproduce

Steps to reproduce the behavior:

  1. Configure in Startup your storage to use blob storage services.AddSingleton<IStorage>(new BlobsStorage(dataConnectionString, "bot-state"));
  2. Configure an object to use as state e.g. "ConversationState" services.AddSingleton<ConversationState>();
  3. OnTurnAsync create property and retrieve conversation state
var conversationDataAccessor = _conversationState.CreateProperty<ConversationData>(nameof(ConversationData));
var conversationData = await conversationDataAccessor.GetAsync(turnContext, () => new ConversationData(), cancellationToken);
  1. Update conversationData and save changes
conversationData.Step = "Feedback";
conversationData.StepUpdated = DateTime.Now;
await _conversationState.SaveChangesAsync(turnContext, true, cancellationToken);
  1. On next turn, update the conversationData.Step and save changes again.
conversationData.Step = "LastStep";
conversationData.StepUpdated = DateTime.Now;
await _conversationState.SaveChangesAsync(turnContext, true, cancellationToken);
  1. Validate the state object in the blob container using the conversation ID
  2. Step will still be "Feedback"

Expected behavior

State in blob container should reflect changes done to the object, holding "LastStep".

Additional context

While using the force parameter, doesn't solve the issue. Using SetAsync does provide a workaround
await conversationDataAccessor.SetAsync(turnContext, conversationData, cancellationToken);

@MathieuMarchant MathieuMarchant added bug Indicates an unexpected problem or an unintended behavior. needs-triage The issue has just been created and it has not been reviewed by the team. labels Jan 27, 2023
@ErwanL08
Copy link

I have the same issue since i update the package from 4.18.1 to 4.19.1 :(

@anishprasad01 anishprasad01 self-assigned this Jan 30, 2023
@anishprasad01
Copy link
Contributor

Thank you for your report.

This is a known issue that was identified recently. We will be addressing this as soon as possible. Please refrain from updating Microsoft.Bot.Builder.Azure packages to 4.19.0 or 4.19.1 until the issue is resolved.

@anishprasad01 anishprasad01 added customer-reported Issue is created by anyone that is not a collaborator in the repository. Bot Services Required for internal Azure reporting. Do not delete. Do not change color. customer-replied-to Indicates that the team has replied to the issue reported by the customer. Do not delete. and removed needs-triage The issue has just been created and it has not been reviewed by the team. labels Jan 30, 2023
tracyboehrer pushed a commit that referenced this issue Feb 13, 2023
…smosDB storage in v4.19.x (#6585)

* Refactor AllowedTypesSerializationBinder to dynamically load types

* Update AllowedTypesSerializationBinder tests
tracyboehrer pushed a commit that referenced this issue Feb 13, 2023
…smosDB storage in v4.19.x (#6585)

* Refactor AllowedTypesSerializationBinder to dynamically load types

* Update AllowedTypesSerializationBinder tests
tracyboehrer pushed a commit that referenced this issue Feb 21, 2023
…ob or CosmosDB storage in v4.19.x (#6585)"

This reverts commit e15b38d.
tracyboehrer added a commit that referenced this issue Feb 23, 2023
* Revert "[#6582, #6584] Incorrect serialization of state when using Blob or CosmosDB storage in v4.19.x (#6585)"

This reverts commit e15b38d.

* Revert "Fix CodeQL SM02211 alert - SerializationBinder (#6549)"

This reverts commit 1ee5f6a.

* Skip TypeNameHandling CodeQL issue from Azure and Blobs storage (#6592)

---------

Co-authored-by: Tracy Boehrer <trboehre@microsoft.com>
Co-authored-by: Joel Mut <62260472+sw-joelmut@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bot Services Required for internal Azure reporting. Do not delete. Do not change color. bug Indicates an unexpected problem or an unintended behavior. customer-replied-to Indicates that the team has replied to the issue reported by the customer. Do not delete. customer-reported Issue is created by anyone that is not a collaborator in the repository.
Projects
None yet
4 participants