PublishedMetadata is unsafe to subclass (not documented)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 598
- Forks
- 168
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 86
Description
And generally, our handling of orphan cleanup around PublishedMetadata seems a bit unsafe and fragile.
Version
Any
Describe the bug
Orphan cleanup relies on the fact that metadata for publications is saved as PublishedMetadata content - very specifically, using that type name.
If it's not created with that precise type name, orphan cleanup will happily delete all such metadata, as it's not strictly associated with a piece of content in the repository, and because create_from_file() is a classmethod
No plugins actually do this as far as I'm aware, but in general the code feels a bit dangerous. I saw https://bugzilla.redhat.com/show_bug.cgi?id=2073183, and while no specific potential causes jump out at me immediately, it feels like there might be a bug lurking in the create_from_file() code. Perhaps even a race condition.
It would be worthwhile to do a broader rethink of how all of this fits together.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading pulpcore/app/tasks/orphan.py at lines 53-55 and pulpcore/app/models/publication.py around line 265, especially the PublishedMetadata handling and create_from_file(). Trace how metadata is associated with content and how orphan cleanup selects records. Done should include an agreed safer design, coverage for subclassing and concurrency cases, and tests demonstrating that valid metadata is not removed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100