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][fix] fastapi: init inner_exception properly #488

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from

Conversation

simahawk
Copy link
Contributor

@simahawk simahawk commented 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 attribute won't be defined yet.

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

Fixes #487

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
@OCA-git-bot
Copy link
Contributor

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

@@ -47,7 +52,6 @@ def handle_error(self, exc):
def _make_response(self, status_mapping, headers_tuple, content):
self.status = status_mapping[:3]
self.headers = dict(headers_tuple)
self.inner_exception = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO you still need to reset the inner_exception each time you process a new response

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lmignon my understanding, but correct me if I'm wrong, is that the dispatcher will be re-initialized for each request. Now, if the assumption of the re-init per request is correct I wouldn't bother handling this differently.

Another point: even assuming you are correct, if you reset it for each iteration you might lose a previous exception. Hence, we should probably do a check if it is valued already and do not override it.

WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simahawk I think I was wrong 😏

@lmignon
Copy link
Contributor

lmignon commented Jan 10, 2025

It would be nice to have a test reproducing this error...

@lmignon lmignon added this to the 16.0 milestone Jan 10, 2025
@lmignon lmignon changed the title [fix] fastapi: init inner_exception properly [16.0][fix] fastapi: init inner_exception properly Jan 10, 2025
@lmignon lmignon added the 16.0 label Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[16.0] fastapi: object has no attribute inner_exception
4 participants