Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0] fastapi error on request #414

Closed
hugomartineznetkia opened this issue Feb 15, 2024 · 11 comments · Fixed by #416
Closed

[16.0] fastapi error on request #414

hugomartineznetkia opened this issue Feb 15, 2024 · 11 comments · Fixed by #416
Labels
bug Something isn't working

Comments

@hugomartineznetkia
Copy link

Module

fastapi

Describe the bug

Error on request:
Traceback (most recent call last):
File "/opt/odoo/custom/src/odoo/odoo/http.py", line 2044, in call
response = request._serve_db()
File "/opt/odoo/custom/src/odoo/odoo/http.py", line 1633, in _serve_db
return service_model.retrying(self._serve_ir_http, self.env)
File "/opt/odoo/custom/src/odoo/odoo/service/model.py", line 133, in retrying
result = func()
File "/opt/odoo/custom/src/odoo/odoo/http.py", line 1660, in _serve_ir_http
response = self.dispatcher.dispatch(rule.endpoint, args)
File "/opt/odoo/custom/src/rest-framework/fastapi/fastapi_dispatcher.py", line 22, in dispatch
environ = self._get_environ()
File "/opt/odoo/custom/src/rest-framework/fastapi/fastapi_dispatcher.py", line 46, in _get_environ
environ["wsgi.input"] = self.request.httprequest._get_stream_for_parsing()
AttributeError: 'HTTPRequest' object has no attribute '_get_stream_for_parsing'

To Reproduce

Affected versions: 16.0

Steps to reproduce the behavior:
1.Install fastapi
2.Configure any endpoint
3.Try to use the endpoint via request/swagger

Additional context
Debian
Doodba
Python 3.10

@hugomartineznetkia hugomartineznetkia added the bug Something isn't working label Feb 15, 2024
@hugomartineznetkia
Copy link
Author

I found that after this commit (OCA/OCB@6758fca) the error appears, so I take this commit (OCA/OCB@a859fd9) to fix it for now.

@florian-dacosta
Copy link

Same error here FYI @lmignon
Although I think this commit is source of the problem : odoo/odoo@cb1d057

@meestaben
Copy link
Contributor

I have run into the same issue today. There is a workaround (accessing the wrapped request) but it's not very nice.

meestaben added a commit to meestaben/rest-framework that referenced this issue Feb 19, 2024
Short-term workaround for the problem described here: OCA#414
@lmignon
Copy link
Contributor

lmignon commented Feb 20, 2024

pfffff I hate odoo.

@Tscunami
Copy link

Tscunami commented Feb 20, 2024

Hello,
I have a similar issue. I have Odoo version 16 hosted on Odoo.sh. The Fastapi module stopped working between 16.2. and 19.2. I get a similar error to @hugomartineznetkia when I try to open Swagger docs on the Swagger URL. It doesn't load, and I get a 500 Internal server error.

I'm getting this error:
`
2024-02-19 15:42:44,909 4 ERROR odoo-staging-conf-11664437 odoo.http: Exception during request handling.
Traceback (most recent call last):
File "/home/odoo/src/odoo/odoo/http.py", line 2044, in call
response = request._serve_db()
File "/home/odoo/src/odoo/odoo/http.py", line 1633, in _serve_db
return service_model.retrying(self._serve_ir_http, self.env)
File "/home/odoo/src/odoo/odoo/service/model.py", line 133, in retrying
result = func()
File "/home/odoo/src/odoo/odoo/http.py", line 1660, in _serve_ir_http
response = self.dispatcher.dispatch(rule.endpoint, args)
File "/home/odoo/src/user/fastapi/fastapi_dispatcher.py", line 22, in dispatch
environ = self._get_environ()
File "/home/odoo/src/user/fastapi/fastapi_dispatcher.py", line 46, in _get_environ
environ["wsgi.input"] = self.request.httprequest._get_stream_for_parsing()
AttributeError: 'HTTPRequest' object has no attribute '_get_stream_for_parsing'
2024-02-19 15:42:44,910 4 INFO odoo-staging-conf-11664437 werkzeug: 91.139.114.205 - - [19/Feb/2024 15:42:44] "GET /api/docs HTTP/1.0" 500 - 2 0.001 0.005
2024-02-19 15:42:44,914 4 ERROR odoo-staging-conf-11664437 werkzeug: Error on request:
Traceback (most recent call last):
File "/home/odoo/src/odoo/odoo/http.py", line 2044, in call
response = request._serve_db()
File "/home/odoo/src/odoo/odoo/http.py", line 1633, in _serve_db
return service_model.retrying(self._serve_ir_http, self.env)
File "/home/odoo/src/odoo/odoo/service/model.py", line 133, in retrying
result = func()
File "/home/odoo/src/odoo/odoo/http.py", line 1660, in _serve_ir_http
response = self.dispatcher.dispatch(rule.endpoint, args)
File "/home/odoo/src/user/fastapi/fastapi_dispatcher.py", line 22, in dispatch
environ = self._get_environ()
File "/home/odoo/src/user/fastapi/fastapi_dispatcher.py", line 46, in _get_environ
environ["wsgi.input"] = self.request.httprequest._get_stream_for_parsing()
AttributeError: 'HTTPRequest' object has no attribute '_get_stream_for_parsing'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/werkzeug/serving.py", line 319, in run_wsgi
execute(self.server.app)
File "/usr/lib/python3/dist-packages/werkzeug/serving.py", line 308, in execute
application_iter = app(environ, start_response)
File "/home/odoo/src/odoo/odoo/http.py", line 2072, in call
return exc.error_response(environ, start_response)
TypeError: 'NoneType' object is not callable - - -
`

I tried the solution mentioned by @meestaben, but I still get the server error; nothing is in the log this time when a server error occurs.

If I try to call some endpoint, it returns me an HTML website with this message:
`

We couldn't find the page you're looking for!

Don't panic. If you think it's our mistake, please send us a message on this page.

`

Everything worked fine on the last Thursday.

This is the last revision when it worked:

image

From this revision, it stopped working:

image

Any help on how to solve this issue would be highly appreciated.

@lmignon
Copy link
Contributor

lmignon commented Feb 20, 2024

However, I have to manage priorities on the project I'm currently working on. So I don't have time to look at it right now. The fix may be simple, but for that I need a bit of time.

lmignon added a commit to acsone/rest-framework that referenced this issue Feb 20, 2024
From odoo/odoo@cb1d057, the orignal werkzeug request is wrapped in a dedicated class to keep under control the attributes developers use. This change add code to make the fastapi addon working with version including this last change and prior version

refs OCA#414
@lmignon
Copy link
Contributor

lmignon commented Feb 20, 2024

@florian-dacosta @Tscunami @hugomartineznetkia Can you test #416. This should fix the issue.

lmignon added a commit to acsone/rest-framework that referenced this issue Feb 20, 2024
From odoo/odoo@cb1d057, the orignal werkzeug request is wrapped in a dedicated class to keep under control the attributes developers use. This change add code to make the fastapi addon working with version including this last change and prior version

refs OCA#414
@Tscunami
Copy link

Hello @lmignon ,

I wanted to confirm that the fix proposed in the pull request has been tested on my end, and it successfully resolves the issue with the Odoo module for version 16.0 latest on Odoo.sh. I have approved the changes in the pull request.

Thank you for your prompt and effective solution to this issue.

Best regards

@lmignon
Copy link
Contributor

lmignon commented Feb 20, 2024

Thank you for the feedback @Tscunami

@meestaben
Copy link
Contributor

Thank you @lmignon 👍

@JanQubiQ
Copy link

Hello @lmignon ,

I'm currently working on migrating from base_rest to fastapi and I realized about this issue. I've tried your fix and it worked for me.

Thanks for the fix 🙌🏼

lmignon added a commit to acsone/rest-framework that referenced this issue Feb 20, 2024
From odoo/odoo@cb1d057, the orignal werkzeug request is wrapped in a dedicated class to keep under control the attributes developers use. This change add code to make the fastapi addon working with version including this last change and prior version

refs OCA#414
nguyenminhchien pushed a commit to nguyenminhchien/rest-framework that referenced this issue Feb 21, 2024
From odoo/odoo@cb1d057, the orignal werkzeug request is wrapped in a dedicated class to keep under control the attributes developers use. This change add code to make the fastapi addon working with version including this last change and prior version

refs OCA#414
nguyenminhchien pushed a commit to nguyenminhchien/rest-framework that referenced this issue Feb 21, 2024
From odoo/odoo@cb1d057, the orignal werkzeug request is wrapped in a dedicated class to keep under control the attributes developers use. This change add code to make the fastapi addon working with version including this last change and prior version

refs OCA#414
renda-dev pushed a commit to PyTech-SRL/rest-framework that referenced this issue Feb 27, 2024
From odoo/odoo@cb1d057, the orignal werkzeug request is wrapped in a dedicated class to keep under control the attributes developers use. This change add code to make the fastapi addon working with version including this last change and prior version

refs OCA#414
renda-dev pushed a commit to PyTech-SRL/rest-framework that referenced this issue Feb 27, 2024
From odoo/odoo@cb1d057, the orignal werkzeug request is wrapped in a dedicated class to keep under control the attributes developers use. This change add code to make the fastapi addon working with version including this last change and prior version

refs OCA#414
astirpe pushed a commit to astirpe/rest-framework that referenced this issue May 19, 2024
From odoo/odoo@cb1d057, the orignal werkzeug request is wrapped in a dedicated class to keep under control the attributes developers use. This change add code to make the fastapi addon working with version including this last change and prior version

refs OCA#414
nguyenminhchien pushed a commit to nguyenminhchien/rest-framework that referenced this issue May 24, 2024
From odoo/odoo@cb1d057, the orignal werkzeug request is wrapped in a dedicated class to keep under control the attributes developers use. This change add code to make the fastapi addon working with version including this last change and prior version

refs OCA#414
sbidoul pushed a commit to nguyenminhchien/rest-framework that referenced this issue May 26, 2024
From odoo/odoo@cb1d057, the orignal werkzeug request is wrapped in a dedicated class to keep under control the attributes developers use. This change add code to make the fastapi addon working with version including this last change and prior version

refs OCA#414
cormaza pushed a commit to cormaza/rest-framework that referenced this issue Nov 8, 2024
From odoo/odoo@cb1d057, the orignal werkzeug request is wrapped in a dedicated class to keep under control the attributes developers use. This change add code to make the fastapi addon working with version including this last change and prior version

refs OCA#414
dnplkndll pushed a commit to Kencove/rest-framework that referenced this issue Dec 14, 2024
From odoo/odoo@cb1d057, the orignal werkzeug request is wrapped in a dedicated class to keep under control the attributes developers use. This change add code to make the fastapi addon working with version including this last change and prior version

refs OCA#414
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants