Azure / Azure/azure-rest-api-specs
## Microsoft.ApiManagement/service/policyFragments@2023-03-01-preview - ROUNDTRIP_INCONSISTENT_PROPERTY && ROUNDTRIP_MISSING_PROPERTY
- Dominant language
- TypeSpec
- Stars
- 3.1k
- Forks
- 5.9k
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 444
Description
## Microsoft.ApiManagement/service/policyFragments@2023-03-01-preview - ROUNDTRIP_INCONSISTENT_PROPERTY && ROUNDTRIP_MISSING_PROPERTY
### Description
I found differences between PUT request body and GET response:
- .properties.format = rawxml: not returned from response
- .properties.value: expect
```
@{
var userId = context.Variables.GetValueOrDefault("UserId", "");
JObject inBody = context.Request.Body?.As();
if (inBody != null) {
inBody.Add("user_id", userId);
}
return inBody.ToString();
}
```
, but got
```
@{
var userId = context.Variables.GetValueOrDefault<string>("UserId", "");
JObject inBody = context.Request.Body?.As<JObject>();
if (inBody != null) {
inBody.Add("user_id", userId);
}
return inBody.ToString();
}
```
```json
{
"properties": {
"description": "some description",
"format": "rawxml" is not returned from response,
"value": Got "\r\n\t\r\n\t@{\r\n var userId = context.Variables.GetValueOrDefault<string>(\"UserId\", \"\");\r\n JObject inBody = context.Request.Body?.As<JObject>();\r\n if (inBody != null) {\r\n inBody.Add(\"user_id\", userId);\r\n }\r\n return inBody.ToString();\r\n }\r\n" in response, expect "\n \n @{\n var userId = context.Variables.GetValueOrDefault(\"UserId\", \"\");\n JObject inBody = context.Request.Body?.As();\n if (inBody != null) {\n inBody.Add(\"user_id\", userId);\n }\n return inBody.ToString();\n }\n\n"
}
}
```
### Details
1. ARM Fully-Qualified Resource Type
```
Microsoft.ApiManagement/service/policyFragments
```
2. API Version
```
2023-03-01-preview
```
3. Swagger issue type
```
Swagger Correctness
```
4. OperationId
```
TODO
e.g., VirtualMachines_Get
```
5. Swagger GitHub permalink
```
TODO,
e.g., https://github.com/Azure/azure-rest-api-specs/blob/60723d13309c8f8060d020a7f3dd9d6e380f0bbd
/specification/compute/resource-manager/Microsoft.Compute/stable/2020-06-01/compute.json#L9065-L9101
```
6. Error code
```
ROUNDTRIP_INCONSISTENT_PROPERTY
ROUNDTRIP_MISSING_PROPERTY
```
7. Request traces
```
PUT https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/acctest0001/providers/Microsoft.ApiManagement/service/acctest0001/policyFragments/henglu002?api-version=2023-03-01-preview
Accept: application/json
Authorization: REDACTED
Content-Length: 627
Content-Type: application/json
User-Agent: HashiCorp Terraform/1.5.2 (+https://www.terraform.io) Terraform Plugin SDK/2.8.0 terraform-provider-azapi/dev pid-222c6c49-1b0a-5959-a213-6608f9eb8820
X-Ms-Correlation-Request-Id: 3b7855a7-3a25-df18-0007-c2aa23380322
--------------------------------------------------------------------------------
{"name":"henglu002","properties":{"description":"some description","format":"rawxml","value":"\u003cfragment\u003e\n \u003cset-variable name=\"UserId\" value=\"@{\n return ((Jwt)context.Variables[\"jwt\"]).Claims.GetValueOrDefault(\"sub\", new string[1]).First();\n }\" /\u003e\n \u003cset-body\u003e@{\n var userId = context.Variables.GetValueOrDefault\u003cstring\u003e(\"UserId\", \"\");\n JObject inBody = context.Request.Body?.As\u003cJObject\u003e();\n if (inBody != null) {\n inBody.Add(\"user_id\", userId);\n }\n return inBody.ToString();\n }\u003c/set-body\u003e\n\u003c/fragment\u003e\n"}}
--------------------------------------------------------------------------------
RESPONSE Status: 202 Accepted
Cache-Control: no-cache
Content-Length: 0
Date: Tue, 15 Aug 2023 05:24:10 GMT
Expires: -1
Location: https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/acctest0001/providers/Microsoft.ApiManagement/service/acctest0001/policyFragments/henglu002?api-version=2023-03-01-preview&asyncId=64db0bfac25cfd1524a3c94b&asyncCode=201&format=rawxml
Pragma: no-cache
Server: Microsoft-HTTPAPI/2.0
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
X-Ms-Correlation-Request-Id: 3b7855a7-3a25-df18-0007-c2aa23380322
X-Ms-Ratelimit-Remaining-Subscription-Writes: 1199
X-Ms-Request-Id: 3b7855a7-3a25-df18-0007-c2aa23380322
X-Ms-Routing-Request-Id: SOUTHEASTASIA:20230815T052410Z:8acaf5c4-0180-42c6-9eb8-b84f6fe6381a
Response contained no body
GET https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/acctest0001/providers/Microsoft.ApiManagement/service/acctest0001/policyFragments/henglu002?api-version=2023-03-01-preview
Accept: application/json
Authorization: REDACTED
User-Agent: HashiCorp Terraform/1.5.2 (+https://www.terraform.io) Terraform Plugin SDK/2.8.0 terraform-provider-azapi/dev pid-222c6c49-1b0a-5959-a213-6608f9eb8820
X-Ms-Correlation-Request-Id: 5cf47a92-28bc-51c1-0f0b-4676f8ca8e62
--------------------------------------------------------------------------------
RESPONSE Status: 200 OK
Cache-Control: no-cache
Content-Type: application/json; charset=utf-8
Date: Tue, 15 Aug 2023 05:24:16 GMT
Etag: "3YrjmwQAAAA="
Expires: -1
Pragma: no-cache
Server: Microsoft-HTTPAPI/2.0
Strict-Transport-Security: max-age=31536000; includeSubDomains
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-Ms-Correlation-Request-Id: 5cf47a92-28bc-51c1-0f0b-4676f8ca8e62
X-Ms-Ratelimit-Remaining-Subscription-Reads: 11997
X-Ms-Request-Id: 5cf47a92-28bc-51c1-0f0b-4676f8ca8e62
X-Ms-Routing-Request-Id: SOUTHEASTASIA:20230815T052417Z:c4ed596b-e465-4d08-a6bd-4b5abce7a2e3
--------------------------------------------------------------------------------
{
"id": "/subscriptions/{subscription_id}/resourceGroups/acctest0001/providers/Microsoft.ApiManagement/service/acctest0001/policyfragments/henglu002",
"type": "Microsoft.ApiManagement/service/policyFragments",
"name": "henglu002",
"properties": {
"description": "some description",
"value": "\r\n\t\r\n\t@{\r\n var userId = context.Variables.GetValueOrDefault<string>(\"UserId\", \"\");\r\n JObject inBody = context.Request.Body?.As<JObject>();\r\n if (inBody != null) {\r\n inBody.Add(\"user_id\", userId);\r\n }\r\n return inBody.ToString();\r\n }\r\n"
}
}
--------------------------------------------------------------------------------
```
### Links
1. [Semantic and Model Violations Reference](https://github.com/Azure/azure-rest-api-specs/blob/main/documentation/Semantic-and-Model-Violations-Reference.md)
2. [S360 action item generator for Swagger issues](https://aka.ms/swaggers360)
Contributor guide
Research direction
Start by locating the Microsoft.ApiManagement/service/policyFragments@2023-03-01-preview definition in the azure-rest-api-specs repository and read the Semantic and Model Violations Reference. Compare its schema with the supplied PUT and GET traces, then determine whether the missing format property and XML transformations are specification or service behavior; done means the discrepancy and affected operation are identified with a confirmed resolution path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi
- Domain
- api, backend-api-design
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100