Skip to content

## Microsoft.ApiManagement/service/policyFragments@2023-03-01-preview - ROUNDTRIP_INCONSISTENT_PROPERTY && ROUNDTRIP_MISSING_PROPERTY #25306

Open
@ms-henglu

Description

@ms-henglu

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
 <fragment>
  <set-variable name="UserId" value="@{
    return ((Jwt)context.Variables["jwt"]).Claims.GetValueOrDefault("sub", new string[1]).First();
  }" />
  <set-body>@{
    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();
  }</set-body>
</fragment>

, but got

 <fragment>
	<set-variable name="UserId" value="@{&#xA;    return ((Jwt)context.Variables[&quot;jwt&quot;]).Claims.GetValueOrDefault(&quot;sub&quot;, new string[1]).First();&#xA;  }" />
	<set-body>@{
    var userId = context.Variables.GetValueOrDefault&lt;string&gt;("UserId", "");
    JObject inBody = context.Request.Body?.As&lt;JObject&gt;();
    if (inBody != null) {
      inBody.Add("user_id", userId);
    }
    return inBody.ToString();
  }</set-body>
</fragment>
{
    "properties": {
        "description": "some description",
        "format": "rawxml" is not returned from response,
        "value": Got "<fragment>\r\n\t<set-variable name=\"UserId\" value=\"@{&#xA;    return ((Jwt)context.Variables[&quot;jwt&quot;]).Claims.GetValueOrDefault(&quot;sub&quot;, new string[1]).First();&#xA;  }\" />\r\n\t<set-body>@{\r\n    var userId = context.Variables.GetValueOrDefault&lt;string&gt;(\"UserId\", \"\");\r\n    JObject inBody = context.Request.Body?.As&lt;JObject&gt;();\r\n    if (inBody != null) {\r\n      inBody.Add(\"user_id\", userId);\r\n    }\r\n    return inBody.ToString();\r\n  }</set-body>\r\n</fragment>" in response, expect "<fragment>\n  <set-variable name=\"UserId\" value=\"@{\n    return ((Jwt)context.Variables[\"jwt\"]).Claims.GetValueOrDefault(\"sub\", new string[1]).First();\n  }\" />\n  <set-body>@{\n    var userId = context.Variables.GetValueOrDefault<string>(\"UserId\", \"\");\n    JObject inBody = context.Request.Body?.As<JObject>();\n    if (inBody != null) {\n      inBody.Add(\"user_id\", userId);\n    }\n    return inBody.ToString();\n  }</set-body>\n</fragment>\n"
    }
}

Details

  1. ARM Fully-Qualified Resource Type
Microsoft.ApiManagement/service/policyFragments
  1. API Version
2023-03-01-preview
  1. Swagger issue type
Swagger Correctness
  1. OperationId
TODO
e.g., VirtualMachines_Get
  1. 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
  1. Error code
ROUNDTRIP_INCONSISTENT_PROPERTY
ROUNDTRIP_MISSING_PROPERTY
  1. 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": "<fragment>\r\n\t<set-variable name=\"UserId\" value=\"@{&#xA;    return ((Jwt)context.Variables[&quot;jwt&quot;]).Claims.GetValueOrDefault(&quot;sub&quot;, new string[1]).First();&#xA;  }\" />\r\n\t<set-body>@{\r\n    var userId = context.Variables.GetValueOrDefault&lt;string&gt;(\"UserId\", \"\");\r\n    JObject inBody = context.Request.Body?.As&lt;JObject&gt;();\r\n    if (inBody != null) {\r\n      inBody.Add(\"user_id\", userId);\r\n    }\r\n    return inBody.ToString();\r\n  }</set-body>\r\n</fragment>"
  }
}
   --------------------------------------------------------------------------------

Links

  1. Semantic and Model Violations Reference
  2. S360 action item generator for Swagger issues

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions