Actions
Issue #8537
closednamed_viewsets erroneously contains models/viewsets from other apps
Status:
CLOSED - WONTFIX
Priority:
Normal
Assignee:
-
Category:
-
Sprint/Milestone:
-
Start date:
Due date:
Estimated time:
Severity:
2. Medium
Version:
Platform Release:
OS:
Triaged:
No
Groomed:
No
Sprint Candidate:
No
Tags:
Sprint:
Quarter:
Description
For each app, we have this named_viewsets attribute that maps models to NamedModelViewSets.
If you examine it for a plugin:
from pulpcore.app.apps import pulp_plugin_configs
pulp_file_config = [c for c in pulp_plugin_configs() if c.label == "file"][0]
print(pulp_file_config.named_viewsets)
You'll see that it contains mappings for models/viewsets outside of the plugin. For example, pulp_file maps models like Repository to RepositoryViewSet:
pulpcore.app.models.repository.Repository: [pulpcore.app.viewsets.repository.RepositoryViewSet],
This is because pulp_file imports these models/viewsets into its viewsets module.
And the code that sets named_viewsets for apps just blindly imports everything from the viewset module.
This could lead to problems when we call get_viewset_for_model
as we iterated through all plugin configs to find mappings. So one plugin could accidentally define a mapping for core for example.
Actions