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: object has no attribute inner_exception #487

Open
gurneyalex opened this issue Jan 9, 2025 · 1 comment · May be fixed by #488
Open

[16.0] fastapi: object has no attribute inner_exception #487

gurneyalex opened this issue Jan 9, 2025 · 1 comment · May be fixed by #488
Labels
bug Something isn't working

Comments

@gurneyalex
Copy link
Member

gurneyalex commented Jan 9, 2025

We are seeing this stack trace in the logs:

Traceback (most recent call last):
  File "/odoo/src/odoo/http.py", line 2061, in __call__
    response = request._serve_db()
  File "/odoo/src/odoo/http.py", line 1649, in _serve_db
    return service_model.retrying(self._serve_ir_http, self.env)
  File "/odoo/src/odoo/service/model.py", line 133, in retrying
    result = func()
  File "/odoo/src/odoo/http.py", line 1676, in _serve_ir_http
    response = self.dispatcher.dispatch(rule.endpoint, args)
  File "/odoo/external-src/rest-framework/extendable_fastapi/fastapi_dispatcher.py", line 19, in dispatch
    return super().dispatch(endpoint, args)
  File "/odoo/external-src/rest-framework/fastapi/fastapi_dispatcher.py", line 34, in dispatch
    if self.inner_exception:
AttributeError: 'FastApiDispatcher' object has no attribute 'inner_exception'

This is with an up-to-date fastapi addon on 16.0

@gurneyalex gurneyalex added the bug Something isn't working label Jan 9, 2025
@simahawk
Copy link
Contributor

simahawk commented Jan 9, 2025

This is the commit https://github.com/OCA/rest-framework/commit/a6b48ad8b01bc254e6a929851e5c412166aee8c3#diff-5ed70c10fa9de8021986ba7d[…]dc29aae6fe04082ba66b5238be0R47

It looks to me that if the app at line 33 does not yield anything for the response you won't have the inner_exceptionattribute set. That attribute is initialized in the wrong place IMO. It should go to __init__.
I'll open a PR.

@simahawk simahawk changed the title fastapi: object has no attribute inner_exception [16.0] fastapi: object has no attribute inner_exception Jan 9, 2025
simahawk added a commit to camptocamp/rest-framework that referenced this issue Jan 9, 2025
It looks to me that if the app does not yield anything for the response
you might encour into an attribute error as the attribut won't be defined yet.

In general, the init method sounds like a better place for shared attributes.

Fixes OCA#487
@simahawk simahawk linked a pull request Jan 9, 2025 that will close this issue
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.

2 participants