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

The client is allowing creating invalid element in Cosmos that cannot be deleted or accessed #1908

Closed
Socolin opened this issue Oct 6, 2020 · 9 comments
Labels
customer-reported Issue created by a customer discussion-wanted Need a discussion on an area Non-SDK Question

Comments

@Socolin
Copy link

Socolin commented Oct 6, 2020

Hello

I have some invalid elements that were created in a cosmos (containting / in the key) and I cannot delete them, do you have any solution about that ?

It would be great if this error could be catch sooner (server validation ? client validation too)

From https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.documents.resource.id?view=azure-dotnet

The following characters are restricted and cannot be used in the Id property: '/', '\', '?', '#'

The id fields should be at least validated client side to catch the problem sooner than when trying to delete an invalid entity that cannot be deleted (event with the bulk)

To Reproduce

ReproCosmos.zip

Expected behavior

  • Server should prevent it
  • Client should throw an exception

Actual behavior
No error until trying to read it or delete it

Environment summary
SDK Version: 3.13.0
OS Version Windows 10

@j82w
Copy link
Contributor

j82w commented Oct 6, 2020

The item can be deleted using the following guide.

The reason the SDK does not have the logic is it adds a lot of overhead. For creates the id is just in the body of the item. It would require the SDK to extract that id then validate the value. Then validate the id. This checks needs to be added in the service, but there are some hard problems with avoiding breaking customers that have items with invalid ids. All service request should be posted at https://feedback.azure.com/forums/263030-azure-cosmos-db?query=id

@j82w j82w added customer-reported Issue created by a customer discussion-wanted Need a discussion on an area labels Oct 6, 2020
@Socolin
Copy link
Author

Socolin commented Oct 6, 2020

The item can be deleted using the following guide.

Thanks it helped :)

Could you add a link to this, from where the doc talk about invalid ids ? here

The reason the SDK does not have the logic is it adds a lot of overhead. For creates the id is just in the body of the item. It would require the SDK to extract that id then validate the value. Then validate the id. This checks needs to be added in the service, but there are some hard problems with avoiding breaking customers that have items with invalid ids. All service request should be posted at https://feedback.azure.com/forums/263030-azure-cosmos-db?query=id

For the sdk I see multiple possibilities:

  • Rename the current method FastCreateItemAsync() with no check and add a new method SafeCreateItemAsync that do the check and mark [Obsolete] the current method
  • Add an optional parameter to CreateItemAsync that allow to validate the id.
  • A mix between the 2 previous idea

@RomanKreisel
Copy link

I just ran in the same issue - we were able to create documents with IDs, which doesn't allow us to retrieve the same documents by their IDs anymore.
I accept, that older clients may have a problem with this breaking change, but you rolled out breaking changes before (#1725 for example), so I see no reason not to do it for this one.

You could even add an option (maybe to Microsoft.Azure.Cosmos.CosmosClient?) to use the old "quick'n'dirty" behavior.

Of course, the best place to fix it, might be the server itself. This way no client would be allowed to create documents with Ids which cannot be retrieved anymore.

@j82w
Copy link
Contributor

j82w commented Mar 26, 2021

This needs to be implemented by the service. The SDK should not be doing this validation. Please contact support to have the Cosmos DB service add the required checks.

@j82w j82w closed this as completed Mar 26, 2021
@Socolin
Copy link
Author

Socolin commented Mar 26, 2021

@j82w Already reported using the support last year, it took 3 weeks to the one in charge of our ticket to understand we wanterd to repot a bug and nothing has been done since, do you have a direct contact with the team in charge and let them know ?

@StefArroyo
Copy link
Contributor

@Socolin Can you fill out this short form w/ the details of the ticket https://forms.office.com/r/qpY2yZUVBq? I can follow up with the team in charge on the status of this ask and reach out to you!

@Socolin
Copy link
Author

Socolin commented Mar 27, 2021

@Socolin Can you fill out this short form w/ the details of the ticket https://forms.office.com/r/qpY2yZUVBq? I can follow up with the team in charge on the status of this ask and reach out to you!

I'm getting the following error message on your link: "You don't have permission to view or respond to this form"

@StefArroyo
Copy link
Contributor

@Socolin Can you fill out this short form w/ the details of the ticket https://forms.office.com/r/qpY2yZUVBq? I can follow up with the team in charge on the status of this ask and reach out to you!

I'm getting the following error message on your link: "You don't have permission to view or respond to this form"

I've fixed the permission issue. Should be working now!

@ghost
Copy link

ghost commented Dec 15, 2021

Closing due to in-activity, pease feel free to re-open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-reported Issue created by a customer discussion-wanted Need a discussion on an area Non-SDK Question
Projects
None yet
Development

No branches or pull requests

4 participants