Connexion: String query params are being chopped off leaving only last character standing

Created on 25 Sep 2018  路  10Comments  路  Source: zalando/connexion

Description

Given https://github.com/zalando/connexion/blob/master/examples/helloworld/swagger/helloworld-api.yaml swagger file, let's add query param to the endpoint

- name: someId
  in: query
  required: true
  type: string

And modify the handler accordingly to accept the parameter.
Now when the flow reaches the function someId will be set but it will be always the last character of the string passed in the request (i.e. via curl or httpie).

Also I've added some printing to the AioHttpApi#get_request function to examine the content of the request.query stuff. Did the same in the couroutine_wrapper wrappers. In both cases I could see the full string as passed in query parameters of the request. That puzzles me a lot.... After the code reaches the decorators execution, i.e. this line:

2018-09-25 09:18:54,127 - ERROR - connexion.decorators.parameter - parameter:wrapper:154 - query_arguments={'someId': '7'}, from_request={'someId': '7'} - {}

We can see that the value is already chopped down.

One last thing. I think that only query_parameters are being truncated. Everything seems to be ok for path_parameters.

Expected behaviour

curl 127.0.0.1:3000/v1/gretting/kornicameister?someId=123-456-789 results in someId being set to 123-456-789

Actual behaviour

someId is 9 (i.e. last character of the string).

Steps to reproduce

!!! will provide link to the repro rep later, can't really do it now !!!

Additional info:

Output of the commands:

  • python --version => 3.7.0
  • pip show connexion | grep "^Version\:" => 1.5.1
  • pip show aiohttp | grep "^Version\:" => 3.4.4
bug

Most helpful comment

@hjacobs I think I might have the fix. Will be posted in few minutes for you and @dutradda to take a look.

All 10 comments

@dtkav @jmcs sorry for pinging here, but I'd like to get some attention to this. It's quite important for me to figure it out so any help is appreciated. Currently working on a comparison of old Flask-Restful and connexion-aiohttp, so getting this up and running to compare perf is quite important :)

Sorry once again and appreciate the help.
FYI. I will try to reproduce this with hello world example later on but perhaps you or someone else could take a quick peek here.

@dtkav @jmcs this the minimal repro repository: https://github.com/kornicameister/aio_connexion_bug

Looping in @dutradda as he implemented the aiohttp support (https://github.com/zalando/connexion/pull/530).

@hjacobs I think I might have the fix. Will be posted in few minutes for you and @dutradda to take a look.

Ok, fix is up. Still testing out but wanted to push it out for you to check it out.

Ok. Tested out other cases for aiohttp meaning those where we say type: array for the format and can specify collectionFormat. Seems like it's working for all as far as my OpenApi/Swagger knowledge is at proper level.

I think the commit 2f074998e31d3077d16c718ca6886b8d61537536 (#613) broken the aiohttp query string. The @kornicameister code fix it

I am happy to hear that ;-).

Nice work! I'm just add the start of my day in Australia, sorry I didn't see your messages.

Np @dtkav, it's midnight for me in Poland ;-). Glad I could squeeze that between putting my kid to sleep and going to sleep myself ;-)

Was this page helpful?
0 / 5 - 0 ratings