rest-framework icon indicating copy to clipboard operation
rest-framework copied to clipboard

[IMP] rest_log: handle odoo.http.Response objects in logs

Open SilvioC2C opened this issue 3 years ago • 5 comments

Handle odoo.http.Response objects when creating logs.

SilvioC2C avatar Oct 05 '22 10:10 SilvioC2C

Hi @simahawk, some modules you are maintaining are being modified, check this out!

OCA-git-bot avatar Oct 05 '22 10:10 OCA-git-bot

Handle odoo.http.Response objects when creating logs.

Can you please explain what you are trying to achieve? Also, rebase and drop the change on README.md.

simahawk avatar Oct 05 '22 11:10 simahawk

@simahawk

Some endpoints will not return a dict as expected by the _dispatch_with_db_logging method (and the other methods called within), but an object of type odoo.http.Response. When that happens, the instance fails to handle it while creating logs (ie: tries to call json.dumps() on such object, which is not allowed). This patch should fix the issue.

SilvioC2C avatar Oct 05 '22 12:10 SilvioC2C

@simahawk

Some endpoints will not return a dict as expected by the _dispatch_with_db_logging method (and the other methods called within), but an object of type odoo.http.Response. When that happens, the instance fails to handle it while creating logs (ie: tries to call json.dumps() on such object, which is not allowed). This patch should fix the issue.

This should be the description of the commit :wink: You can also shorten the message by removing "in logs" which is redundant for "rest_log".

simahawk avatar Oct 06 '22 06:10 simahawk

@simahawk Added headers to result, also added unit tests. Mind taking a look again? :sweat_smile:

SilvioC2C avatar Oct 06 '22 15:10 SilvioC2C

/ocabot merge minor

simahawk avatar Oct 18 '22 12:10 simahawk

What a great day to merge this nice PR. Let's do it! Prepared branch 13.0-ocabot-merge-pr-296-by-simahawk-bump-minor, awaiting test results.

OCA-git-bot avatar Oct 18 '22 12:10 OCA-git-bot

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

OCA-git-bot avatar Oct 18 '22 13:10 OCA-git-bot

Congratulations, your PR was merged at cddd0ae7757a8b65af0814fb13a37baec344fb1d. Thanks a lot for contributing to OCA. ❤️

OCA-git-bot avatar Oct 18 '22 13:10 OCA-git-bot