Skip to content

[typespec-ts] Query Parameters Encoding Issues for $select, *, and tags=key=value #3935

@minhanh-phan

Description

@minhanh-phan

We're migrating App Configuration services to typespec and we're running into issues with query parameters

Issues

Raw emitter output without workarounds Expected URL
/kv/sortQueryParams19?%2524select=key&api-version=2023-11-01&label=dev /kv/sortQueryParams19?$select=key&api-version=2023-11-01&label=dev
/kv?api-version=2023-11-01&key=%2A&label=dev&tags=tag2%3Dvalue2 /kv?api-version=2023-11-01&key=*&label=dev&tags=tag2%3Dvalue2
  1. $Select is double-encoded.

In models.tsp, we have the query parameters defined here as $Select. In the generation, the emitter writes the parameter name $Select literally into the URI template in operations.ts. Then this is passed into expandUrlTemplate and gets encoded the second time, so it becomes %2524Select. The workaround for this is to manually modify the generated operations.ts file back to $Select.

Expected behavior: the URL request should contain $Select=...

  1. * is encoded by default & tags=tag3=value3 is not encoded if skipUrlEncoding is set

App Configuration allows wildcard filter *, so we can set key=*. When passing through expandUrlTemplate, it is now encoded to key=%2A.

We found out we can set skipUrlEncoding to ensure * is not encoded, but then tags3=value3 will no longer be encoded correctly

Expected behavior: the URL request should contain key=* & tags=tag2=value2

For more context:

tsp-location.yaml

directory: specification/appconfiguration/data-plane/AppConfiguration
commit: 4ec78287ae650c72e27c67ae8126f9d58a8254b5
repo: Azure/azure-rest-api-specs

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions