flask-restx icon indicating copy to clipboard operation
flask-restx copied to clipboard

Fix: Working outside of request context

Open dhanababum opened this issue 4 years ago • 3 comments

RuntimeError: Working outside of application context.

This typically means that you attempted to use functionality that needed to interface with the current application object in some way. To solve this, set up an application context with app.app_context().

https://github.com/python-restx/flask-restx/blob/master/flask_restx/marshalling.py#L251 --> this line is protected by has_app_context https://github.com/python-restx/flask-restx/blob/master/flask_restx/marshalling.py#L252 --> this line is not protected by has_request_context

I have integrated marshal_with serializer to database SQLAlchemy models But getting the RuntimeError: Working outside of request context

Corrected the code and successfully ran tox tests.

dhanababum avatar Jul 26 '21 17:07 dhanababum

Codecov Report

Merging #360 (d5ac614) into master (88497ce) will decrease coverage by 0.00%. The diff coverage is 100.00%.

:exclamation: Current head d5ac614 differs from pull request most recent head eb274dd. Consider uploading reports for the commit eb274dd to get more accurate results Impacted file tree graph

@@            Coverage Diff             @@
##           master     #360      +/-   ##
==========================================
- Coverage   96.86%   96.86%   -0.01%     
==========================================
  Files          20       20              
  Lines        2741     2740       -1     
==========================================
- Hits         2655     2654       -1     
  Misses         86       86              
Impacted Files Coverage Δ
flask_restx/marshalling.py 98.21% <100.00%> (ø)
flask_restx/api.py 96.75% <0.00%> (-0.01%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 88497ce...eb274dd. Read the comment docs.

codecov[bot] avatar Aug 16 '21 13:08 codecov[bot]

LGTM. Can you think of any cases where this could cause a problem? I can't think of any.

j5awry avatar Aug 16 '21 13:08 j5awry

Hi @j5awry, Any update on this?

dhanababum avatar Jun 30 '22 12:06 dhanababum