Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 14:48
    radiantone edited #440
  • 14:48
    radiantone edited #440
  • 14:47
    radiantone opened #440
  • 14:47
    radiantone labeled #440
  • May 15 05:51
    cmpunches labeled #439
  • May 15 05:51
    cmpunches opened #439
  • May 14 08:37
    thedumbterminal edited #438
  • May 14 08:36
    thedumbterminal labeled #438
  • May 14 08:36
    thedumbterminal opened #438
  • May 14 00:07
    boompig commented #437
  • May 14 00:05
    boompig opened #437
  • May 14 00:05
    boompig labeled #437
  • May 13 17:49
    JavaScriptDude commented #116
  • May 13 12:49
    ReznikovRoman commented #135
  • May 13 12:00
    abeiertz commented #59
  • May 12 18:48
    lyonsaj commented #192
  • May 10 05:55
    busoff edited #435
  • May 07 14:12
    ankurcharan commented #151
  • May 02 21:41
    mdylan2 commented #403
  • May 02 21:41
    mdylan2 commented #403
John Chittum
@j5awry
Looking at it, we might be able to do something similar to what happens here: https://github.com/flasgger/flasgger/blob/master/flasgger/base.py#L582
the way the view is generally built is very different, but creating a couple wrap funcs that can wrap an entire view may be possible
but it'll take some digging. is there an issue up for this already (i still need to dig through more issue backlog)
E-Kalla
@E-Kalla

what's it actually returning? What's the 500 and the stacktrace in the log?

I sent some screen , I reproduced your pastebin to catch an exception https://prnt.sc/123j36f and handle it with my function https://prnt.sc/123j4lg but when I test the request I have HttpError 500 instead of 418

John Chittum
@j5awry
what are the app logs saying in conjunction with the 500? Are the app logs quiet and it's just returning 500, or is the application throwing a stacktrace?
E-Kalla
@E-Kalla

what are the app logs saying in conjunction with the 500? Are the app logs quiet and it's just returning 500, or is the application throwing a stacktrace?

https://prnt.sc/1258amm
Here is the stacktrace

E-Kalla
@E-Kalla
https://prnt.sc/1259av5 I have Cors missing allow origin
John Chittum
@j5awry
Hm, i'm still not sure what's happening here. Sorry. Something inside the app is generating an error that's not getting caught.
i can't tell from that stacktrace if it's related to the error_handling or something else (such as CORS)
E-Kalla
@E-Kalla
np, thank you for yours answers ;)
John Chittum
@j5awry
I'd say if you can start on a more simple example -- something as basic as possible, and then start adding layers, and catching when it works or fails
if it fails at the very beginning, say, just instantiating an API, custom error handler, and raising, then we'll know it's something in the custom error, error handler, etc. Then add in the marshalling, cors, etc
E-Kalla
@E-Kalla

hello @j5awry
I successed to make the simple example on your pastebin working.

I tried to implement it on a very simple get routes but It didnt work , https://pastebin.ubuntu.com/p/8NWdRCgz38/
I made to many tests and it always return http error 500.
I'll continue my research

E-Kalla
@E-Kalla
Ok , I found It https://github.com/pallets/flask/blob/2ab91446f608755affba035650c1dd74b825a018/flask/app.py#L1446-L1450
It looks flask raise http Error 500 before the exception get caught by the handler with debug mode on
I disabled debug mod and It works
E-Kalla
@E-Kalla
Hey ,
I needed the debug mode on so I found another solution
I set PROPAGATE_EXCEPTIONS = False
https://prnt.sc/12956at
But It looks weird because we can see here https://github.com/python-restx/flask-restx/blob/66471c5223e0237762fc2722d680229bb68e0d16/flask_restx/api.py#L675
It says the opposite, so I am a little confused
@j5awry
Abdur-Rahmaan Janhangeer
@Abdur-rahmaanJ
@j5awry After many failed attempts for basic auth, i think best is disable docs in production
John Chittum
@j5awry
@Abdur-rahmaanJ If you don't mind me asking, is this an on-prem or cloud hosted? And is it possible to add authentication at other layers? It depends a lot on your setup, but something like using JWT with NGinx, or x509 based auth at Apache Webserver are other possibilities. But there's a lot of nuance there. I do think we need to figure out a better way of handling the pre-generated doc endpoint, and I think what flasgger is doing could be an interesting entry point. but it's going to take code change in flask-restx
@E-Kalla : what version of flask-restx are you using again? And if you haven't, could you open an issue on our github? I think we're seeing various things that'd be nice to track in an issue.
E-Kalla
@E-Kalla

@E-Kalla : what version of flask-restx are you using again? And if you haven't, could you open an issue on our github? I think we're seeing various things that'd be nice to track in an issue.

I'm using flask-restx 0.3.0

E-Kalla
@E-Kalla
I opened an issue here python-restx/flask-restx#305 tell me if something is not clear , first time for me
Jason Weir
@Gidgidonihah
I just tracked down a bug in our own code related to flask_restx error handling when swapping from flask_restplus. The bug was that we were relying on the restplus bug that swallowed errors and we didn't know it. We had an error handler to handle custom error codes which should have dropped us into this block but instead we hit the else and threw a ValueError on line 705. Because flask_restplus swallowed errors, it worked, when swapping, it no longer did.
We tracked it down to the fact that the error handler was registered on the flask api, rather than the api instance. Fixed that and it worked as expected, but my questions is:
Should it have ignored error handlers on the app and only looked at api error handlers?
If the answer is yes, so be it, but I had to ask
John Chittum
@j5awry

@Gidgidonihah : Reading the code, the intent is that errorhandlers get checked for the restx.API and it's children (restx.API.namespace). It wouldn't make sense, to me, for the framework to go up the chain as well.

So self + children vs. self + parents + children. self + children makes sense to me for checking handlers. But I may be misinterpreting the question?

@E-Kalla : thank you. I think there's good information to start looking at things more closely. Sorry we can't react quickly. The community is small. Having it in an issue will help us keep track of comments and have higher visibility. I can also cross-check against current and past issues a bit easier.
Jason Weir
@Gidgidonihah
@j5awry I don't think you are misinterpreting. That was how I read the code as well. However, it did lead to an easy bug like this. Let me phrase the question like this. When would I want to register a handler on the flask app, and not have the framework use it? In this case, self is a child of the app, so it could also make sense that it bubbles up to that level, as it were.
1 reply
E-Kalla
@E-Kalla
Hello,
I have a question about marshal models.
How can I make a self reference in a model ?
https://prnt.sc/12kvzl2
I want my model 'error' can contain himself recursively.
But i'm struggling with ...
E-Kalla
@E-Kalla
actually , I want to this : https://marshmallow.readthedocs.io/en/stable/nesting.html#nesting-a-schema-within-itself
Is it possible without using marshmallow ?
Abdur-Rahmaan Janhangeer
@Abdur-rahmaanJ
@j5awry See https://aaronluna.dev/series/flask-api-tutorial/part-3/ "LINES 6, 14: The API will implement Bearer token authentication ..." and the comment below it

@Abdur-rahmaanJ If you don't mind me asking, is this an on-prem or cloud hosted? And is it possible to add authentication at other layers? It depends a lot on your setup, but something like using JWT with NGinx, or x509 based auth at Apache Webserver are other possibilities. But there's a lot of nuance there. I do think we need to figure out a better way of handling the pre-generated doc endpoint, and I think what flasgger is doing could be an interesting entry point. but it's going to take code change in flask-restx

Cloud-hosted, server-based auth is a great option also but see the above

1 reply
John Chittum
@j5awry
@E-Kalla : woof, self-reference. So, JSONSchema at a certain point started enabling more of that. I'd have to check on versioning. a lot of how the models are written and validated is based on JSONSchema v. 4. I'd have to look more closely at how to deal with something nested. But, unfortunately, restx models aren't as feature rich as Marshmallow
Henshal B
@henshalb
Hello, I have got a query.. How to add an additional GET into a class, may with a different name?
Henshal B
@henshalb
Just like an action decorator for django
John Chittum
@j5awry
hey all, we're cutting 0.4.0 release right now! flask and werkzeug both released 2.0.0. unfortunately, there are a few breaking changes we'll need to work through. You can pin flask and werkzeug yourself, but we're also pinning flask-restx for the moment till some upstream things fix, and we can make sure we've got any breaking changes accounted for
there are also some improvements and bugfixes. checkout the CHANGELOG.rst for quick hits
John Chittum
@j5awry
so i dropped by https://pypistats.org/packages/flask-restx thinking it'd show some interesting info -- our largest percentage of install is on 3.4 according to this
that's...worrisome since we've been talking about deprecating < 3.6. I'm wondering why there are so many 3.4 instals
alincmt
@ClimenteA
Hi, do you know how can I add @ns.doc (OpenApi) decorator with some default parameters in Namespace class?
I opened a question on stackoverflow (maybe others will need it): https://stackoverflow.com/questions/67530938/add-doc-decorators-on-namespace-instantiation-flask-restx
E-Kalla
@E-Kalla
Hello, I'm using marshmallow schema now , do you know the best way to documentate an API with marshmallow schema ?
I tried to keep @marshal_with(marshmallowschema)
But It didnt work, no error but swagger don't display anything.
I found https://apispec.readthedocs.io/en/latest/ is it the only solution ?
Thank you
John Chittum
@j5awry
honestly, if you're investing in marshmallow, apispec or moving to flask-smorest. smorest is the Marshmallow-Code version of flask-restx
E-Kalla
@E-Kalla
ok ;) and do you have some news about the deprecated Flask-RESTX request parse ? https://flask-restx.readthedocs.io/en/latest/parsing.html
John Chittum
@j5awry
nope. we keep saying "deprecated" because the original project had said so. But we haven't worked out anything different/better and regularly get people asking us to keep it
E-Kalla
@E-Kalla
ok thank you for reply !
Hamdi Burak Usul
@hbusul
Hello, we need a contributor to review pull request #341 . @j5awry was looking at the issue but we did not hear anything for a month. It would be really nice to use new werkzeug and flask with the flask-restx .
John Chittum
@j5awry
@hbusul sorry, it's been a very busy month. I've pulled in everything. I put up the changelog for the version. If anyone wants to give it a quick look before I merge and push the new version
Hamdi Burak Usul
@hbusul
@j5awry I can imagine, thanks for handling that :D . Our tests seems to do fine with the latest commit
E-Kalla
@E-Kalla
Hello ,
I have this issue for a while python-restx/flask-restx#314
I will try to take a look on the restx code but if you have an idea about where could this problem come from because it's really problematic.
If you have a polymorph field , you have to use marshmallow , then migrate all your api documentation on apispec, which is a very tedious work.
And even with apispec , swagger don't display the models correctly.
thank you
John Chittum
@j5awry
I've just run a release 0.5.0. it should end up in Pypi sometime~ish. I published the release on github, and bumped all the files appropriately
and the package.json should be a semver compliant thing now. i tried to hack on bumpr this morning, but since it appears to also be dead, i gave up