connexion icon indicating copy to clipboard operation
connexion copied to clipboard

Fix inconsistent behaviour when a charset is defined in Content-Type header value with an invalid and valid json #1202

Open scoulomb opened this issue 4 years ago • 7 comments

Fixes

Issue https://github.com/zalando/connexion/issues/1202

scoulomb avatar Apr 02 '20 22:04 scoulomb

I tested it locally here: https://github.com/scoulomb/zalando_connexion_sample (+buildLocalLib branch)

I did not see specific unit test to update, what would you advise?

scoulomb avatar Apr 02 '20 22:04 scoulomb

Coverage Status

Coverage increased (+0.6%) to 96.879% when pulling eb9b6a98833b785a885b8b66f6f69003e0aee7b6 on scoulomb:Issue1202 into bed4b95205205861bd6014282d0f61d50231d3ac on zalando:master.

coveralls avatar Apr 02 '20 22:04 coveralls

Fix loss of coverage here: https://github.com/zalando/connexion/blob/c99dda68f4cad9e36815267eb68898220499ee5c/connexion/decorators/validation.py#L142

scoulomb avatar Apr 11 '20 17:04 scoulomb

I added unit test in test_json_validation.py However loss of coverage was due to the fact that in the former version of the code we were doing tuple unpacking after the split which could lead to a ValueError exception

>>> mimetype.split('/')
['application-json']
>>> a,b = mimetype.split('/')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: not enough values to unpack (expected 2, got 1)

IMO it is a workaround to test a side effect of the function outsside of it: As we now test separator presence it is useless to catch this exception so I will remove the try/except block

scoulomb avatar Apr 11 '20 18:04 scoulomb

Hello @hjacobs , I fixed https://github.com/zalando/connexion/issues/1202 in this PR. Would you mind please have a look? Thanks a lot.

scoulomb avatar Apr 16 '20 13:04 scoulomb

@hjacobs do you think this PR is mergeable, or should I rework on it?

scoulomb avatar Jun 18 '20 12:06 scoulomb

This seems like a good change @scoulomb. If you're still interested in getting it merged, please rebase on and target this PR to the v2 branch.

RobbeSneyders avatar Apr 14 '22 18:04 RobbeSneyders