#22986 Better logic to ensure context.entity never contains a Project