Azure / Azure/azure-rest-api-specs

[BUG][APIM][2024-05-01] Deleting default Product returns 412 PreconditionFailed under concurrent tests

Open
#37,004 0 comments 0 reactions 0 assignees View on GitHub
API Management bug customer-reported Mgmt question Service Attention
Dominant language
TypeSpec
Stars
3.1k
Forks
5.9k
Avg merge
2d 22h
Merged PRs (30d)
444

Description

### API Spec link

https://github.com/Azure/azure-rest-api-specs/blob/a61456ebadb3ad73cee898b8bdd2f14885663332/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/apimproducts.json#L344

### API Spec version

2024-05-01

### Describe the bug

When using the API Management REST API version 2024-05-01, attempting to delete the default Product (starter) immediately after creating an API Management service sometimes fails with 412 PreconditionFailed.

Key observations:

- The issue only occurs when multiple tests run concurrently, where each test creates its own API Management instance (names include random suffixes, so no naming collision occurs).

- Running a single test case in isolation works fine — the default Product can be deleted successfully.

- The problem occurs even if the request includes:

```
the latest ETag retrieved via a GET immediately before DELETE, or
the header If-Match: *.
```

- Older API versions do not have this problem: v2022-08-01 → works

### Expected behavior

- The DELETE request for the default Product should succeed whether executed individually or concurrently, as long as the latest ETag or If-Match: * is provided/No If-Match.

- Behavior should be consistent with older API versions (v2022-08-01 API version that do not provide If-Match do not have this problem).

### Actual behavior

- Under concurrent execution with v2024-05-01, the DELETE request for the default Product fails with 412 PreconditionFailed, even though each APIM instance is unique and isolated.

- In isolated runs, the same request succeeds.

- Older API versions (v2022-08-01) do not exhibit this issue.

### Reproduction Steps

- Run multiple concurrent tests, each of which:

1. Creates a new API Management service instance with a unique (randomized) name.

2. Immediately attempts to DELETE the default Product (starter) using API version 2024-05-01.

```
If-Match:

or If-Match: *

```

- Some of the tests fail with:

```
Status: 412 Precondition Failed
Error1: PreconditionFailed: Resource was modified since last retrieval
Error2: PreconditionFailed: Exception of type 'Microsoft.WindowsAzure.ApiManagement.Management.Core.Exceptions.PreconditionFailedException' was thrown.

```

- Run the same test individually (not in parallel). The DELETE request succeeds.

- Run the same concurrent scenario with v2022-08-01 API → all DELETE requests succeed(Even if If-Match is not specified).

### Environment

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the linked specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/apimproducts.json entry and compare the default Product DELETE behavior with the reported 2022-08-01 behavior. Reproduce the concurrent create-and-delete scenario with the documented ETag and If-Match variants; done means determining whether the API specification can describe or correct this service-side 412 failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi
Domain
api, cloud
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.