FusionAuth/fusionauth-netcore-client

Incorrect handling of URL Parameters

TruDan opened this issue · 3 comments

I'm trying to call IFusionAuthAsyncClient.SearchUsersByIdsAsync(List<string> ids) but if say i give the id's a list containing:
["1a4a9247-2b9d-45d2-ae1e-4714756b5a58","5a1505df-677e-44e3-9c09-d858087eac7b"]

This results in an exception:

Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.
   at async Task<IEnumerable<UserDto>> HeroBalancer.Repo.Stores.FusionAuth.FusionAuthUserStore.ReadByIds(Guid[] ids) in /build/src/Repo/Stores/FusionAuth/FusionAuthUserStore.cs:line 73

In FusionAuth, there is a very unhelpful error message which doesnt tell me much about the issue:
java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986

Eventually, i find in our Nginx-Ingress-Controller logs, the request that was actually made:

2020-06-03 11:33:32 | 10.244.1.219 - - [03/Jun/2020:09:33:32 +0000] "GET /api/user/search?ids=System.Collections.Generic.List%601[System.String] HTTP/1.1" 400 1985 "-" "-" 367 0.003 [default-fusionauth-80] [] 10.244.0.159:9011 1985 0.004 400 f6eaaa076541fc2a1d196711554fb795

Here you can see the ids parameter has been serialized incorrectly. According to the API documentation at https://fusionauth.io/docs/v1/tech/apis/users#search-for-users
this should be serialised as so:
ids=1a4a9247-2b9d-45d2-ae1e-4714756b5a58&ids=5a1505df-677e-44e3-9c09-d858087eac7b

Related to this, in io.fusionauth.DefaultRESTClient "parameters" should be a List<KeyValuePair<string, string>> then you may add multiple parameters with the same Key. Otherwise you must handle this differently

This is fixed in #22 - Can you merge this? It's a big roadblock for us currently, forcing us to package our own fork of this library to NuGet so we can use the changes and make progress with our feature releases

PR is included in released version 1.17.1 of the client.
https://www.nuget.org/packages/FusionAuth.Client/