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: Escape invalid characters in the id value #25721

Merged
merged 2 commits into from
Aug 26, 2021
Merged

Conversation

AndriySvyryd
Copy link
Member

Also change the DateTime format to ISO 8601

Fixes #25100

Also change the DateTime format to ISO 8601

Fixes #25100
if (propertyValue == null)
{
builder.Append("null");
} else
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} else
}
else

var startingIndex = builder.Length;
return builder.Append(stringValue)
.Replace("|", "^|", startingIndex, builder.Length - startingIndex)
.Replace("/", "^2F", startingIndex, builder.Length - startingIndex)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm missing context, but why do the extra characters need to be escaped (I get that pipe is our custom separator within generated IDs, but the others)? Is there a specific reason for the choice of caret as the escape character?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.documents.resource.id?view=azure-dotnet for the list of invalid characters.

I've tried to URLEncode them, but it seems that the server decodes the values before storing them, so it still fails. Therefore I used the caret as an alternative encoding.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good, thanks for the info. A link in a comment could be helpful for future readers.

@AndriySvyryd AndriySvyryd merged commit 0368eda into release/6.0 Aug 26, 2021
@AndriySvyryd AndriySvyryd deleted the Issue25100 branch August 26, 2021 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cosmos Provider - Date in Primary Key cannot be later deleted
2 participants