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

Cosmosdb latest sdk throw this error : Message: {"Errors":["PartitionKey extracted from document doesn't match the one specified in the header"]} #15161

Closed
MuhamedSalihSeyedIbrahim opened this issue May 6, 2021 · 12 comments
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. Cosmos customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@MuhamedSalihSeyedIbrahim

Hi Team,
Description:
we recently flooded this mentioned exception.
Message: {"Errors":["PartitionKey extracted from document doesn't match the one specified in the header"]}

Note:

  1. our item doc that is about to upsert always have proper id and partition keys set and we did not pass any other field to upsert lib function (Eg:. client.upsert({ id:xx, partitionKey:aa}); )
  2. we use partition key and id as seperate values which are always sting
  3. we never modify partition key related header as we use cosmosdb sdk to interact with db
  4. we cant able to replicate in local but it occur daily in function app(azure functions)

Runtime : nodejs v12.18.3

Cosmosdb version : 3.11.0

Error:
Message: {"Errors":["PartitionKey extracted from document doesn't match the one specified in the header"]}
PartitionKeyRangeId: 0, IsValid: True, StatusCode: 400, SubStatusCode: 1001, RequestCharge: 1.24, ItemLSN: -1, , UsingLocalLSN: False, TransportException: null, ResourceType: Document, OperationType: Upsert , SDK: Microsoft.Azure.Documents.Common/2.11.0 |  

Need to know why it occurs and a way to fix it?

Thanks in advance,
Muhamed

@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels May 6, 2021
@ramya-rao-a ramya-rao-a added Client This issue points to a problem in the data-plane of the library. Cosmos labels May 6, 2021
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label May 6, 2021
@ghost ghost added the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label May 6, 2021
@zfoster
Copy link
Contributor

zfoster commented May 6, 2021

hey @MuhamedSalihSeyedIbrahim, is this still an issue if you downgrade to 3.10.6?

@MuhamedSalihSeyedIbrahim
Copy link
Author

MuhamedSalihSeyedIbrahim commented May 6, 2021

@zfoster
i have tried with v3.9.5 and v3.11.0.
Ok give me some time i shall try that particular mentioned version and revert back.

May I know the cause of this particular issue?

Point to consider:
we do blind upsert after retrieval and update of non partition or id field.

@zfoster
Copy link
Contributor

zfoster commented May 7, 2021

I don't necessarily know the cause yet, I've seen this error before caused by chunked encoding not being stitched back together correctly

@zfoster
Copy link
Contributor

zfoster commented May 7, 2021

If you have core-rest-pipeline (peer dependency) it has to be version 1.0.2 or higher I believe for the encoding to correctly work

@MuhamedSalihSeyedIbrahim
Copy link
Author

@zfoster,
No, we are not using core-rest-pipeline.

I have deployed with latest version and also the mentioned version for observation.

I have locally tried to replicate it
I have following observation when I tried to replicate it:

  1. When we have cosmosdb container which have partition key and id as same key in db json and when we try upsert or create a doc with the particual id/partition key as null or undefined this error occurs.

  2. When we have cosmosdb container with id and partion key are different key in db json doc and We are trying to shall copy or do a proto copy of function using "dbdoc =Object.create(dbJsonDoc)" and then try to insert or upsert it. The error is thrown
    Note:
    A. The dbdoc which return of obect.create(), is empty object when tried to insert it throw the error
    B. When we try to create or upsert a empty object "{}"(code) its upserting / inserting data

we are still observing if find anything I shall keep this thread updated.

@MuhamedSalihSeyedIbrahim
Copy link
Author

MuhamedSalihSeyedIbrahim commented May 7, 2021

Step we followed to replicate:
1st case:
Create a db container with doc structure
{id: , data: }

DbcontainerInstance.upsert({data:10})
// last line throw error with code 400 and substatus code 1001

2nd case:

Create container with doc structure
{a:,b:{ c: } , d: }

We retrieved data from db:
Const updatedDoc = object.create();
Await DbcontainerObject.upsert(updatedDoc)
// last line throw error with code 400 and substatus code 1001

@zfoster
Copy link
Contributor

zfoster commented May 7, 2021

I'll try to reproduce. It is still happening with version 3.10.6?

@MuhamedSalihSeyedIbrahim
Copy link
Author

MuhamedSalihSeyedIbrahim commented May 7, 2021

Yes, but I believe its not due to sdk version, I can reproduce in local with 3.11 , 3.10.6 and the version we uses in dev server( 3.9.5) with cases i tried.

Still I have made changes and deployed to dev env with fix of removing object.create function as well as mentioned upgrade of cosmosdb sdk to version 3.10.6 and
want to confirm in the dev env if the error still occur after this fix.

@zfoster
Copy link
Contributor

zfoster commented May 10, 2021

@MuhamedSalihSeyedIbrahim is the error still occurring in the dev env?

@MuhamedSalihSeyedIbrahim
Copy link
Author

@zfoster - No,
After the fix given, I observe no Partition key errors till now (cosmosdb sdk version used -3.9.5 / 3.10.6 / 3.11.0).

@zfoster
Copy link
Contributor

zfoster commented May 11, 2021

great, happy it's resolved and good to know for the future

@zfoster zfoster closed this as completed May 11, 2021
@MuhamedSalihSeyedIbrahim
Copy link
Author

@zfoster thanks🙋🏻‍♂️

openapi-sdkautomation bot pushed a commit to AzureSDKAutomation/azure-sdk-for-js that referenced this issue Jul 15, 2021
Update description for RBAC flag in Key Vault (Azure#15161)

* Update description for RBAC flag in Key Vault

* Update keyvault.json

* Update keyvault.json

* Update keyvault.json
@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. Cosmos customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

No branches or pull requests

3 participants