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

Merged
merged 1 commit into from
Jan 30, 2025

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

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@lmignon
Copy link
Contributor

lmignon commented Jan 30, 2025

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 16.0-ocabot-merge-pr-488-by-lmignon-bump-nobump, awaiting test results.

OCA-git-bot added a commit that referenced this pull request Jan 30, 2025
Signed-off-by lmignon
@OCA-git-bot
Copy link
Contributor

@lmignon your merge command was aborted due to failed check(s), which you can inspect on this commit of 16.0-ocabot-merge-pr-488-by-lmignon-bump-nobump.

After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red.

@lmignon
Copy link
Contributor

lmignon commented Jan 30, 2025

/ocabot merge patch

@OCA-git-bot
Copy link
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 16.0-ocabot-merge-pr-488-by-lmignon-bump-patch, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit bc7e457 into OCA:16.0 Jan 30, 2025
7 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at b8dd3a4. Thanks a lot for contributing to OCA. ❤️

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