Skip to content

Error on Updating FastAPI enpoint #510

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

Open
veryberry opened this issue Mar 19, 2025 · 6 comments
Open

Error on Updating FastAPI enpoint #510

veryberry opened this issue Mar 19, 2025 · 6 comments
Labels
bug Something isn't working

Comments

@veryberry
Copy link

Module

fastapi

Describe the bug

File "/fastapi/models/fastapi_endpoint.py", line 201, in _reset_app
self._reset_app_cache_marker.clear_cache(self)
AttributeError: 'function' object has no attribute 'clear_cache'

To Reproduce

Affected versions:
16.0

Steps to reproduce the behavior:

  1. Change root_path on any existing endpoint
@veryberry veryberry added the bug Something isn't working label Mar 19, 2025
@veryberry
Copy link
Author

veryberry commented Mar 19, 2025

@lmignon I think you are the most appropriate person to take over it.
Honestly, I do not understand the underlying sense of this construct
mb you intended to clear registry cache? self.env.registry.clear_cache()?

    def _reset_app(self):
        self._reset_app_cache_marker.clear_cache()

    @tools.ormcache()
    def _reset_app_cache_marker(self):
        """This methos is used to get a way to mark the orm cache as dirty
        when the app is reset. By marking the cache as dirty, the system
        will signal to others instances that the cache is not up to date
        and that they should invalidate their cache as well. This is required
        to ensure that any change requiring a reset of the app is propagated
        to all the running instances.
        """

@lmignon
Copy link
Contributor

lmignon commented Mar 19, 2025

@veryberry I'm not able to reproduce this issue on 16.0

Image

@lmignon
Copy link
Contributor

lmignon commented Mar 19, 2025

@veryberry I'm pretty sure you encounter the problem with the PR https://github.com/OCA/rest-framework/pull/499/files#diff-dc35ba10e9b915f31315c36ff5cb8f18a0489bbb617b20d073c07d6de6c469b1R202 since the method clear_cache is no more available on methods decorated with the ormcache decorator. The right fix is indeed to replace the line self._reset_app_cache_marker.clear_cache(self) with self.env.registry.clear_cache(). This should trigger the invalidation of all the caches of the odoo instances connected to the same database and defacto the invalidation of the fastapi app cache.
Can you confirm? If I'm right, it could be nice to let a comment on #499 😏

@veryberry
Copy link
Author

Thanks @lmignon you are right, the issue is actual for 17.0+
I'll check the fix in my environment and add a comment.

@veryberry
Copy link
Author

veryberry commented Mar 19, 2025

In this case method _reset_app_cache_marker is still actual or can be removed?

@lmignon
Copy link
Contributor

lmignon commented Mar 19, 2025

This method should be removed but a comment before the call to registry.clear_cache to explain why it's done would be appreciated.

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

No branches or pull requests

2 participants