AppConfiguration icon indicating copy to clipboard operation
AppConfiguration copied to clipboard

AzureAppConfiguration Options.Select Errors on Multiple Segment Wildcards

Open HashTagDotNet opened this issue 5 years ago • 3 comments

Microsoft.Extensions.Configuration.AzureAppConfiguration, Version=3.0.0.0, Culture=neutral,

When I use a '*' wild card in any AzureAppConfigurationOptions.Select() with multiple comma delimited segments, I get an error.

options.Select("dummy-selector,dummy-selector","\0");  // (succeeds) no wild cards, multiple 

options.Select("dummy-Selector*","\0");  // (succeeds) wild card, single segment

options.Select("dummy-selector*,dummy-selector-2","\0"); // (fails) wild card as first in series 

options.Select("dummy-selector,dummy-selector-2*","\0"); // (fails) wild card as second in series

Request

GET /kv/?key=dummy-selector%2A%2Cdummy-selector-2&label=%00&api-version=1.0 HTTP/1.1
Host: ******
Accept: application/vnd.microsoft.appconfig.kv+json
Correlation-Context: RequestType=Startup,Host=IISExpress
x-ms-client-request-id: 917cf1cd-ac63-4981-b892-f9d9594bc30a
x-ms-return-client-request-id: true
User-Agent: Microsoft.Extensions.Configuration.AzureAppConfiguration/3.0.0.0 azsdk-net-Data.AppConfiguration/1.0.0-preview.5+244f59a4499e01fdee834c397b4457f1442200bd,(.NET Core 3.1.0; Microsoft Windows 10.0.18362)
x-ms-content-sha256: 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=
Date: Thu, 12 Dec 2019 17:36:44 GMT
Authorization:  **************
Sync-Token: zAJw6V16=MDotMSM3MDE3NjA=
Request-Id: |650c9af-4b83518de9196c35.1.

Response

Azure.RequestFailedException: Service request failed.
Status: 400 (Bad Request)

Content:
{"type":"https://azconfig.io/errors/invalid-argument","title":"Invalid request parameter 'key'","name":"key","detail":"key(14): Invalid character","pos":14,"status":400}

Headers:
Server: openresty/1.15.8.1
Date: Thu, 12 Dec 2019 17:25:30 GMT
Transfer-Encoding: chunked
Connection: keep-alive
x-ms-request-id: 763a6d2b-2500-40e7-a1f3-04199b77ae1f
x-ms-client-request-id: 7f073d35-ffec-494c-adf2-e2e08562fe10
x-ms-correlation-request-id: 763a6d2b-2500-40e7-a1f3-04199b77ae1f
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, PUT, POST, DELETE, PATCH, OPTIONS
Access-Control-Allow-Headers: DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, x-ms-retry-after, x-ms-request-id, WWW-Authenticate
Access-Control-Expose-Headers: DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Authorization, x-ms-client-request-id, x-ms-content-sha256, x-ms-date, host, Accept, Accept-Datetime, Date, If-Match, If-None-Match, Sync-Token, x-ms-return-client-request-id, ETag, Last-Modified, Link, Memento-Datetime, x-ms-retry-after, x-ms-request-id, WWW-Authenticate
Strict-Transport-Security: max-age=15724800; includeSubDomains
Content-Type: application/vnd.microsoft.appconfig.kv+json; charset=utf-8

   at Azure.Data.AppConfiguration.ConfigurationClient.GetConfigurationSettingsPageAsync(SettingSelector selector, String pageLink, CancellationToken cancellationToken)
   at Azure.Core.PageResponseEnumerator.FuncAsyncPageable`1.AsPages(String continuationToken, Nullable`1 pageSizeHint)+MoveNext()
   at Azure.Core.PageResponseEnumerator.FuncAsyncPageable`1.AsPages(String continuationToken, Nullable`1 pageSizeHint)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
   at Azure.AsyncPageable`1.GetAsyncEnumerator(CancellationToken cancellationToken)+MoveNext()
   at Azure.AsyncPageable`1.GetAsyncEnumerator(CancellationToken cancellationToken)+MoveNext()
   at Azure.AsyncPageable`1.GetAsyncEnumerator(CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
   at Microsoft.Extensions.Configuration.AzureAppConfiguration.AzureAppConfigurationProvider.<>c__DisplayClass14_3.<<LoadAll>b__4>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.Extensions.Configuration.AzureAppConfiguration.AzureAppConfigurationProvider.<>c__DisplayClass14_3.<<LoadAll>b__4>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.Extensions.Configuration.AzureAppConfiguration.TracingUtils.CallWithRequestTracing(Boolean tracingEnabled, RequestType requestType, HostType hostType, Func`1 clientCall)
   at Microsoft.Extensions.Configuration.AzureAppConfiguration.AzureAppConfigurationProvider.CallWithRequestTracing(Func`1 clientCall)
   at Microsoft.Extensions.Configuration.AzureAppConfiguration.AzureAppConfigurationProvider.LoadAll()
   at Microsoft.Extensions.Configuration.AzureAppConfiguration.AzureAppConfigurationProvider.Load()
   at Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList`1 providers)
   at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
   at Microsoft.Extensions.Hosting.HostBuilder.BuildAppConfiguration()
   at Microsoft.Extensions.Hosting.HostBuilder.Build()

Work Around

Use separate options.Select() statements for each wild card selector. This work around results in separate calls to Azure for each options.Select() definition.

HashTagDotNet avatar Dec 12 '19 17:12 HashTagDotNet

Hi @HashTagDotNet similar to #212, this is by design. Using wildcard and comma together is not a supported filter. We, however, need improvement of the documentation for easier discovery of this information.

https://github.com/Azure/AppConfiguration/blob/master/docs/REST/kv.md#filtering

zhenlan avatar Dec 12 '19 18:12 zhenlan

Perhaps this information could be returned in the API response error message. That might save somebody else a significant amount of work.

"Invalid character" doesn't give me much more information than "something really bad happened".

Suggestion: { "type":"https://azconfig.io/errors/invalid-argument", "title":"Invalid request parameter 'key'", "name":"key", "detail":"key(14): Invalid character. Delimited wild-card key selectors are not supported. Make separate calls to the service. See your client's documentation for more details", "pos":14, "status":400} }

I'm sure you can't comment, but will being made to make multiple calls to the API affect the cost of using this service? I'm assuming there might be a per-call or per-key type of charge in the future.

HashTagDotNet avatar Dec 12 '19 18:12 HashTagDotNet

Thanks for the suggestion @HashTagDotNet. We will consider it.

The pricing plan can be found at https://github.com/Azure/AppConfiguration-Announcements/issues/2. The filtering support could be enriched in the future. The config provider library is making necessary calls based on what is currently supported by the REST API.

zhenlan avatar Dec 12 '19 18:12 zhenlan