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

PartitionKey value must be supplied for this operation. #34

Open
Bill7zz opened this issue Mar 28, 2019 · 3 comments
Open

PartitionKey value must be supplied for this operation. #34

Bill7zz opened this issue Mar 28, 2019 · 3 comments
Labels
bug Something isn't working

Comments

@Bill7zz
Copy link

Bill7zz commented Mar 28, 2019

Versions

botbuilder 4.3.0
botbuilder-azure 4.3.4
nodejs version v10.14.2
Windows 10 pro v1803

Describe the bug

When performing a delete operation in a partitioned cosmosDB collection, the following error is thrown:

“{  
   “code”:“BadRequest”,
   “message”:   “PartitionKey value must be supplied for this operation.\r\nActivityId:b46cf62e-d77f-4911-97d4-b8e86186a348,
   \r\nRequestStartTime:2019-03   -27   T20:17:05.5558598   Z,
   RequestEndTime:2019-03   -27   T20:17:05.5558598   Z,
   Number of regions attempted:1   \r\n,
   Microsoft.Azure.Documents.Common/2.2.0.0”
}”

To Reproduce

Steps to reproduce the behavior:

  1. Install the AzureCosmoDb emulator

  2. Create a partitioned collection and insert a new document (Sample image below)

2.1 Use the following information to create a new Cosmos Database in the emulator:

Database name: bot-cosmos-DB
Collection name: bot-collection
PartitionKey: /city

2.2 Add a new document using the following information

{
    "id": "001",
    "name": "contoso",
    "city": "EEUU"
}
  1. Use the echobot-with-counter

  2. Connect the bot with the CosmosDb created

const policyConfigurator = (policy) => policy.DisableSSLVerification = true;
const getSettings = () => ({
    serviceEndpoint: 'https://localhost:8081',
    authKey: 'C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==',
    databaseId: 'bot-cosmos-db',
    collectionId: 'bot-collection'
});
  1. Update the code to attempt to delete the document
    5.1 Insert the next code in the onTurn method of the echoBot class
const storage = new CosmosDbStorage(getSettings(), policyConfigurator);

        if (turnContext.activity.type === ActivityTypes.Message) {

            try {
                await storage.delete([turnContext.activity.text]);     
            } catch (ex) {
                await turnContext.sendActivity(`Error message when trying to delete in cosmos DB storage`);
                await turnContext.sendActivity(`"${ex.body}"`);
            }

        } else {
            // Generic handler for all other activity types.
            await turnContext.sendActivity(`insert the document id to delete`);
        }
        // Save state changes
        await this.conversationState.saveChanges(turnContext);
    }
  1. Run the bot.
  • Insert the document id of the document created before. (sample imagen below)

Expected behavior

Delete the document successfully

Screenshots

The partitioned collection
image

After, the following result was found.
image

Additional context

@Bill7zz Bill7zz added the bug Something isn't working label Mar 28, 2019
@gasper-az
Copy link

Reminder: Don't forget to add the related MS PR (# 1537) when promoting to MS

@gasper-az
Copy link

LGTM

@Aliandi
Copy link

Aliandi commented Mar 28, 2019

Also, for the subitems, dont use a bullet, use a 1.1 format
Something like
1.
1.1.
1.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants