Skip to content

[FIX] No panic on an old open request for __init__#539

Closed
mmahrouss wants to merge 1 commit intoalphafrom
alpha-no-panic-create-custom-ep-mdms
Closed

[FIX] No panic on an old open request for __init__#539
mmahrouss wants to merge 1 commit intoalphafrom
alpha-no-panic-create-custom-ep-mdms

Conversation

@mmahrouss
Copy link
Collaborator

Before this was causing panic, while it is safe to just ignore it

This PR, makes it panic only on unreachable cases, otherwise, silently leave. It is safe to not process a deleted __init__,py

Before this was causing panic, while it is safe to just ignore it

This PR, makes it panic only on unreachable cases, otherwise, silently leave.
It is safe to not process a deleted `__init__,py`
@mmahrouss mmahrouss added this to the 1.2.0 milestone Feb 4, 2026
@mmahrouss mmahrouss requested a review from fda-odoo February 4, 2026 08:30
@mmahrouss mmahrouss self-assigned this Feb 4, 2026
@mmahrouss mmahrouss added the bug Something isn't working label Feb 4, 2026
// Another notification will come for the deletion of the file, so we just warn here.
warn_or_panic!("Trying to create a custom entrypoint on a namespace symbol: {:?}", new_sym.borrow().paths());
if Path::new(file_path).exists() || !file_path.ends_with("__init__.py") {
// a file exists, or does not end with __init__.py
Copy link
Collaborator

@fda-odoo fda-odoo Feb 9, 2026

Choose a reason for hiding this comment

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

are you sure that !file_path.ends_with("__init__.py") is the right test?
It's confusing me. If we are on a namespace symbol, I thought you would want to test if an __init__.py file exists or not in the namespace. Something like:
Path::new(file_path.join("__init__.py").exists()
I don't see the point of Path::new(file_path).exists() either

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So the goal of this condition is not panic when we have an __init__.py file that does not exist anymore.

This is the case that we can predict, and is safe to skip, other cases we should still warn or panic, which in theory should be unreachable.

I was able to replicate the panic, by having a folder ( custom entry points) having __init__ and __manifest__ and then trigering a rebuild by editing a file in the orm, while it is reloading, I delete __init__ and then doing a hover in __manifest__

Then when create_from_path gets called during the rebuild, (due to the py package being in self import), then since we check if __init__.py exists or not, we get false, so we create a namespace which is wrong.

But it should be okay, because there should come a didClose and/or didDelete and then we will delete the symbol.

So that is why we want to only catch the case that there is a file that exists and is not __Init__ then something else is wrong and we want to catch it.

Another thing to note is, probably #541 already will prevent the panic from happenign at all, because usually the symbol will be removed correctly, while it was not before, but since I am not sure about all the cases, it might still be safe to keep the change of the check here?

@fda-odoo
Copy link
Collaborator

fda-odoo commented Feb 9, 2026

This code should be in unreachable code. If we reach it, we should not hide the panic, as it's an error

@fda-odoo fda-odoo closed this Feb 9, 2026
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 this pull request may close these issues.

2 participants