You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are continuously addressing and improving the SDK, if possible, make sure the problem persist in the latest SDK version.
Describe the bug
In the case where an issue occurs while executing a pre-trigger insert, the API appears to correctly throw a Conflict 409 response, however, the response contains no reason to indicate what has gone wrong.
usingSystem;usingSystem.Collections.Generic;usingSystem.Threading.Tasks;usingMicrosoft.Azure.Cosmos;usingMicrosoft.Azure.Cosmos.Fluent;usingMicrosoft.Azure.Cosmos.Scripts;usingNewtonsoft.Json;namespaceCosmos409{publicclassProgram{publicconststringLocalConnectionString="AccountEndpoint=https://localhost:8081/;AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==;";publicconststringDatabaseName="test";publicconststringContainerName="jobs";publicconststringSetJobNumberTrigger="SetJobNumber";publicstaticasyncTaskMain(string[]args){varcosmosClient=newCosmosClientBuilder(LocalConnectionString).Build();try{awaitcosmosClient.GetDatabase(DatabaseName).DeleteAsync();}catch(CosmosException){// data doesn't exist}vardatabaseResponse=awaitcosmosClient.CreateDatabaseAsync(DatabaseName,400);varcontainerResponse=awaitdatabaseResponse.Database.DefineContainer(ContainerName,"/investigationKey").WithUniqueKey().Path("/investigationKey").Attach().WithUniqueKey().Path("/jobNumber").Attach().CreateIfNotExistsAsync();awaitcontainerResponse.Container.Scripts.CreateTriggerAsync(newTriggerProperties{Id=SetJobNumberTrigger,TriggerType=TriggerType.Pre,TriggerOperation=TriggerOperation.Create,Body=@"function setJobNumber() { var context = getContext(); var request = context.getRequest(); var containerManager = context.getCollection(); var containerLink = containerManager.getSelfLink() var documentToCreate = request.getBody(); var jobNumberQuery = ""SELECT VALUE MAX(r.jobNumber) from root r WHERE r.investigationKey = '"" + documentToCreate['investigationKey'] + ""'""; containerManager.queryDocuments(containerLink, jobNumberQuery, function(err, countValue) { if (err) throw new Error(err.message); documentToCreate['jobNumber'] = (countValue.length > 0 ? countValue[0] : 0) + 1; }); // update the document that will be created request.setBody(documentToCreate); }",});varjob=newJob{Id=Guid.NewGuid(),InvestigationKey="test"};awaitcontainerResponse.Container.CreateItemAsync(job,null,newItemRequestOptions{PreTriggers=newList<string>{SetJobNumberTrigger}});job.Id=Guid.NewGuid();try{// this will currently fail due to the ill defined unique key, however, the 409 response doesn't indicate any reason at allawaitcontainerResponse.Container.CreateItemAsync(job,null,newItemRequestOptions{PreTriggers=newList<string>{SetJobNumberTrigger}});}catch(CosmosExceptione){Console.WriteLine(e.Message);}Console.WriteLine("<3");Console.ReadLine();}}publicclassJob{[JsonProperty("id")]publicGuidId{get;set;}[JsonProperty("investigationKey")]publicstringInvestigationKey{get;set;}[JsonProperty("jobNumber")]publicintJobNumber{get;set;}}}
Expected behavior
Conflict 409 response with a reason to indicate to the user what has gone wrong.
Actual behavior
Conflict 409 response with an empty reason field
Environment summary
SDK Version: 3.1.1
OS Version (e.g. Windows, Linux, MacOSX) Windows
Additional context
The text was updated successfully, but these errors were encountered:
Describe the bug
In the case where an issue occurs while executing a pre-trigger insert, the API appears to correctly throw a Conflict 409 response, however, the response contains no reason to indicate what has gone wrong.
To Reproduce
From #667
Expected behavior
Conflict 409 response with a reason to indicate to the user what has gone wrong.
Actual behavior
Conflict 409 response with an empty reason field
Environment summary
SDK Version: 3.1.1
OS Version (e.g. Windows, Linux, MacOSX) Windows
Additional context
The text was updated successfully, but these errors were encountered: