_save_prefixes_txt crashes with DoesNotExist when two domains produce identical prefixes.txt
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 57/100
Research direction
Start with MavenMetadata in pulp_maven/app/models.py and compare its global sha256 uniqueness with the domain-scoped constraints. Then read _save_prefixes_txt and _save_metadata_content in pulp_maven/app/tasks/__init__.py and check for existing tests around metadata generation. Done means identical metadata content across domains no longer causes DoesNotExist during modify_repo.
Written by the indexing model from the issue text.
Description
Description
_save_prefixes_txt crashes with MavenMetadata.DoesNotExist when two domains generate a prefixes.txt with identical content (same sha256). This makes modify_repo unusable on the second domain.
Root cause
MavenMetadata.sha256 has a global unique=True constraint (not scoped to _pulp_domain):
# pulp_maven/app/models.py
sha256 = models.CharField(max_length=64, null=False, unique=True, db_index=True)
In _save_prefixes_txt, the save-or-get pattern assumes the IntegrityError came from the domain-scoped unique_together constraint, but it actually comes from the global sha256 uniqueness:
# pulp_maven/app/tasks/__init__.py, line ~83-103
metadata_content = MavenMetadata(
group_id="", artifact_id="", version=None,
filename=PREFIXES_TXT_FILENAME,
sha256=artifact.sha256,
_pulp_domain=pulp_domain,
)
try:
with transaction.atomic():
metadata_content.save()
except IntegrityError:
metadata_content = MavenMetadata.objects.get(
group_id="", artifact_id="", version=None,
filename=PREFIXES_TXT_FILENAME,
sha256=artifact.sha256,
_pulp_domain=pulp_domain, # <-- filters by THIS domain
)
When domain A and domain B produce prefixes.txt with identical content:
- Domain A's
.save()succeeds — sha256 is new globally. - Domain B's
.save()raisesIntegrityError— sha256 already exists (from domain A). - Domain B's
.get()filters by_pulp_domain=B, but the record belongs to domain A →DoesNotExist.
The same pattern exists in _save_metadata_content (line ~518-529), which is vulnerable to the same bug for any metadata file that happens to have identical content across domains.
How to reproduce
- In a multi-domain Pulp instance, create a Maven repository in domain A.
- Upload a single artifact with
group_id="org.example"and callmodify_repoto add it. This succeeds and generates aprefixes.txtcontaining only/org/example. - In domain B, create a Maven repository and upload an artifact with the same
group_id="org.example". - Call
modify_repoon domain B → crashes withMavenMetadata matching query does not exist.
Traceback
File ".../pulpcore/app/tasks/repository.py", line 259, in add_and_remove
with repository.new_version(base_version=base_version) as new_version:
File ".../pulpcore/app/models/repository.py", line 1513, in __exit__
repository.finalize_new_version(self)
File ".../pulp_maven/app/models.py", line 639, in finalize_new_version
self._generate_metadata(new_version)
File ".../pulp_maven/app/models.py", line 1045, in _generate_metadata
prefixes_pks = _save_prefixes_txt(current_prefixes, self.pulp_domain)
File ".../pulp_maven/app/tasks/__init__.py", line 96, in _save_prefixes_txt
metadata_content = MavenMetadata.objects.get(
django.core.exceptions.ObjectDoesNotExist: MavenMetadata matching query does not exist.
Suggested fix
Either:
-
Scope the
sha256uniqueness to the domain — replace the globalunique=Trueon thesha256field with inclusion in theunique_togetherconstraint (which already includes_pulp_domain). -
Handle the cross-domain collision in the fallback — when the
IntegrityErroris from the globalsha256constraint, look up the existing record without thesha256filter and update it, or share the content record across domains.
- Dominant language
- Python
- Stars
- 5
- Forks
- 30
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 26
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing 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.
More from pulp/pulp_maven
-
Nightly s3 unit tests fail under pytest 9.2.0: 'S3Storage' object has no attribute 'location'Possibly taken @dkliban claimed this 4 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
pulp/pulp_maven#566 ·
Maintainers usually reply within 1 day
-
InvalidIndex exception triggers pulpcore deprecation warning in CIPossibly taken @git-hyagi claimed this 25 days ago. OpenIssue
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
pulp/pulp_maven#535 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 45/100
pulp/pulp_maven#568 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
pulp/pulp_maven#563 ·
Maintainers usually reply within 1 day
-
Redeploying the same coordinates with different content returns 201 but keeps serving the old filePossibly taken @aevnsvi claimed this 14 days ago. Open
Difficulty 4/5 1-2 days Newbie friendliness 58/100
pulp/pulp_maven#551 ·
Maintainers usually reply within 1 day
Similar issues
-
DBFS append mode silently overwrites existing filesPossibly taken @IlyaKhalafi claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
fsspec/filesystem_spec#2429 ·
Maintainers usually reply within 1 day
-
[Bug]: Retrieval rerank fallback statistics stay zero after provider failurePossibly taken A pull request linked to this issue is open or already merged. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
volcengine/OpenViking#7014 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
fedora-copr/copr#4600 ·
Maintainers usually reply within 2 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ansys/pydpf-core#3620 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day