OCA / rest-framework

GNU Affero General Public License v3.0
309 stars 297 forks source link

[16.0]Fast API Endpoints Cache #391

Open hassan510-cmd opened 11 months ago

hassan510-cmd commented 11 months ago

Module

fast API

Describe the bug

when I try to create a new app with such an endpoint as root_path into data dir and some routes, it's required to update the module to be able to access this endpoint

To Reproduce

Affected versions:

Steps to reproduce the behavior:

  1. create a new module depending on fastapi with some routes
  2. create an endpoint in the data dir to be created during the installation
  3. try to access even the docs URL it'll not founded
  4. go to apps -> update your custom module
  5. try to access it again, it works fine now

Expected behavior the newly created endpoint should work properly without the need to update the module

lmignon commented 11 months ago

@hassan510-cmd IMO this problem comes from the endpoint_route_handler addon. @simahawk what do you thing about?

hassan510-cmd commented 11 months ago

@lmignon i try to upgrade endpoint_route_handler instead of upgrade my module, it work fine also

I think you are right

hassan510-cmd commented 11 months ago

@lmignon @simahawk anything new about this issue ?

hassan510-cmd commented 11 months ago

Dears, after some dubbing, I have found that the first synced endpoint not working until you sync another one, and I tried to get an explanation for this behavior : 1- we have a table called "endpoint_route" This table contains new custom routes 2- we have a sequence called "endpoint_route_version" that has 2 triggers before inserting and update 3- according to the incremental start with 1 and INCREMENT BY 1 at first time the "last_version" col in "endpoint_route_version" equal to 1 4- after syncing the first endpoint the last version does not change 5- in the override method called routing_map its check on 2 conditions, the second one check if the _endpoint_route_last_version is less than the "last_version" col in "endpoint_route_version" which at first sync endpoint will be equal so, there is no new route will be mapped until you sync another endpoint so the _endpoint_route_last_version will be less than the "last_version" col in "endpoint_route_version" so the super method will work properly case of clear the cls._routing_map

I suggest 2 solutions to handle the first sync endpoint: 1- change check condition to be cls._endpoint_route_last_version <= last_version or 2- add 3rd condition which delete the "_routing_map" attr so the cls._routing_map will get cleared also

In this fork i have applied the first solution

github-actions[bot] commented 5 months ago

There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.