8000 Cosmos doesn't support pipe | in partition keys / document IDs · Issue #241 · cfworker/cfworker · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Cosmos doesn't support pipe | in partition keys / document IDs #241

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

Open
JoshZA opened this issue Jan 29, 2023 · 1 comment
Open

Cosmos doesn't support pipe | in partition keys / document IDs #241

JoshZA opened this issue Jan 29, 2023 · 1 comment

Comments

@JoshZA
Copy link
JoshZA commented Jan 29, 2023

Using version: "@cfworker/cosmos": "1.13.5",

This doesn't work:

       const res = await this.client.getDocument<CustomerUser>({
            docId: 'User|105dbf77-a3bb-4688-9fc7-9506c96d52d6',
            partitionKey: 'User|105dbf77-a3bb-4688-9fc7-9506c96d52d6'
        });

Cosmos returns:

401
code: 'Unauthorized',
message: "The input authorization token can't serve the request. The wrong key is being used or the expected payload is not built as per the protocol.

Calls to similar documents without pipes in the Id/partition key work correctly

@jdanyow
Copy link
Member
jdanyow commented Aug 22, 2024

Try changing the following line and let me know if that resolves the issue for you.

https://github.com/cfworker/cfworker/blob/main/packages/cosmos/src/client.ts#L429

    if (args.partitionKey) {
      headers.set(
        'x-ms-documentdb-partitionkey',
-        escapeNonASCII(JSON.stringify([args.partitionKey]))
+       JSON.stringify([args.partitionKey])
      );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0