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

Cosmos: Pipe character is escaped for key value when creating a new document #20665

Closed
nellstephanj opened this issue Apr 17, 2020 · 3 comments
Closed
Labels
area-cosmos closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-bug
Milestone

Comments

@nellstephanj
Copy link

We receive an id from a third party application where the format of the id is <name>|<guid> for example "test|36f47ad4-e23f-43f1-8c37-304df4e6193a".

When creating a document and marking this value as the key-value EF escapes the pipe character for the id so the example ends up being test/|36f47ad4-e23f-43f1-8c37-304df4e6193a. If the value is not marked as the key-value it is not escaped. Using EF to retrieve the same document works fine however when viewing the values using the Azure Data Explorer it breaks with the following message:

image

When creating the same document using the same key using the Cosmos SDK the character is not escaped and I am able to view the document using Azure Data Explorer.

The fluent setup I used

builder.Property(user => user.UserId).HasMaxLength(100);
builder.HasKey(user => user.UserId);
builder.HasPartitionKey(user => user.regionCode);

and saving the user

    context.Add(new User
    {
        UserId = "test|36f47ad4-ef3f-43f1-8c67-304df4e6193a",
        Name= "Test",
        regionCode = "1-Test"
    });

    await context.SaveChangesAsync()

Further technical details

EF Core version: 3.1.3
EF Core.Cosmos version 3.1.3
Target framework: NET Core 3.1

@AndriySvyryd
Copy link
Member

These characters can't be used in the resource id: '/', '\', '?', '#', source
We can instead url encode the '|' char, but that might be blocked by Azure/azure-cosmos-dotnet-v2#458

@vsadams
Copy link

vsadams commented Jun 15, 2020

Is this slated for the next release?

@AndriySvyryd
Copy link
Member

@vsadams Yes

@AndriySvyryd AndriySvyryd added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Jun 15, 2020
@AndriySvyryd AndriySvyryd removed their assignment Jun 15, 2020
@ajcvickers ajcvickers modified the milestones: 5.0.0, 5.0.0-preview7 Jun 22, 2020
@ajcvickers ajcvickers modified the milestones: 5.0.0-preview7, 5.0.0 Nov 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-cosmos closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-bug
Projects
None yet
Development

No branches or pull requests

4 participants