question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Azure.Data.Tables TableClient.CreateIfNotExistsAsync throws with 409 conflict instead of returning null

See original GitHub issue

Describe the bug The documentation says that TableClient.CreateIfNotExistsAsync will return null if the table already exists. It actually doesn’t. It throws with Status of Conflict

Expected behavior CreateIfNotExistsAsync implies it will not throw if it does exist. Otherwise what value is this method over Create ?

Actual behavior (include Exception or Stack Trace)

It throws RequestFailedException with Status of 409

ps: Q: what is the difference between this library and Microsoft.Azure.Cosmos.Table which is not deprecated, but not updated since 2020. Q: Why not name this library Azure.Storage.Tables to match Azure.Storage.Blobs

To Reproduce Steps to reproduce the behavior (include a code snippet, screenshot, or any additional information that might help us reproduce the issue)

  1. Run the below code on a table of your choice. 2.Set a breakpoint in the catch clause on the second run.
               try
                {
                    await this.tableClient.CreateIfNotExistsAsync(cancellationToken);
                }
                catch (RequestFailedException exception) when (exception.Status == (int)HttpStatusCode.Conflict)
                {
                    // Already exists.
                }

Environment:

  • Name and version of the Library package used: [e.g. Azure.Data.Table12.2.1] Azure.Data.Tables 12.2.1
  • Hosting platform or OS and .NET runtime version (dotnet --info output for .NET Core projects): [e.g. Azure AppService or Windows 10 .NET Framework 4.8]

This is just debugging in the IDE from a console app. .Net 5.0.

  • IDE and version : [e.g. Visual Studio 16.3] Visual studio 16.11.5.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
nschuesslercommented, Oct 26, 2021

Oy vey, you are right. I was manually testing and turned on first chance exceptions looking for calls to GetEntityAsync<T> that didn’t have catches for Status=404 and was thinking I also needed handling on the CreateTableIfNotExistsAsync when this triggered.

Looks like this is by design. I’ll remove the catch for that api.

0reactions
christothescommented, Oct 26, 2021

Does this only throw in the debugger when it is configured to break on all exceptions, including first chance? There is a first chance exception that occurs there, but it is caught and handled.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure Table Storage Exception: 409 Conflict unexpected?
The following code ( table.CreateIfNotExistsAsync() ) throws the error: The remote server returned an error: (409) Conflict. CloudTableClient ...
Read more >
[QUERY] Tables CreateIfNotExists Error Logs · Issue #28084
Why does the following code, throw a 409 (conflict) if the table exists. The purpose of this call is to create a table...
Read more >
HTTP 409 code when you use CreateIfNotExists with Azure ...
It seems that the HTTP Error is thrown each time when a new user session is an initiate, and some information is read...
Read more >
TableClient.CreateIfNotExistsAsync(CancellationToken) ...
Returns. A Response<T> containing properties of the table. If the table already exists, then Status is 409.
Read more >
Azure Blob Storage error codes
Error code HTTP status code User message BlobAlreadyExists Conflict (409) The specified blob already exists. BlobNotFound Not Found (404) The specified blob does not exist. ContainerAlreadyExists...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found