Repository navigation
Maven pom rewrites add a second <repositories> or <dependencyManagement> section when the existing one is self-closed or has a comment before <dependencies>, so Maven refuses the pom #342
Description
Activity
- addedbugSomething isn't workingSomething isn't workingbughuntFound by a scheduled package-manager bug-hunt agentFound by a scheduled package-manager bug-hunt agentpm:mavenMavenMaven
on Sep 30, 2026 mikolalysenko commented
on Sep 30, 2026 CollaboratorAuthorMore actions[agent] Triaged:
priority:p3(Maven). Not a duplicate: as the report says, this is a missed anchor that creates a duplicate top-level element, not an edit that lands inside a comment or profile (#259). No open or merged PR fixes it. The suspect sites (insert_maven_repositorywithpom.contains("<repositories>"), the<dependencyManagement>\s*<dependencies>regex, andmaven_repo.rsbuild_repo_editanchoring on</repositories>) are all ad-hoc text anchors on the pom. A structure-aware pom editor shared by the hosted and vendored paths would fix this together with #259, so the two should be looked at together when the Maven work is picked up.
Generated by Claude Code
- added a commit that references this issue
on Sep 30, 2026 mikolalysenko commented
on Oct 1, 2026 CollaboratorAuthorMore actions[agent] Re-triage (Maven bug-hunt, ledger #318): the hosted case still reproduces on main
2463257(the v5 consolidation, #277).I ran the
e2e_redirect_maven_buildcapstone's real writer with the consumer pom's only change being a self-closed<repositories/>before</project>.scan --mode hosted --jsonexits 0 withredirect.redirected: 1andvex.statements: 1, and the rewritten pom has a second<repositories>:- Maven 3.9.11 (2 of 2 runs):
mvn -o validate→[FATAL] Non-parseable POM …/pom.xml: Duplicated tag: 'repositories' (position: START_TAG seen ...<repositories/>\n <repositories>... @16:17) - Maven 4.0.0-rc-7:
Non-parseable POM …: Unable to read model: Duplicated tag: 'repositories'
I didn't re-check the vendored side this run. v5 routes reactors through a new backend (
vendor/jvm/maven_reactor.rs), and single-POM projects still usemaven_repo.rs.
Generated by Claude Code
- Maven 3.9.11 (2 of 2 runs):
mikolalysenko commented
on Oct 3, 2026 CollaboratorAuthorMore actions[agent] Architecture audit (ecosystems and formats): the hosted rows here come from
insert_maven_repository/insert_maven_dependency_managementanchoring on exact text. #717 locates those anchors through the sharedformats::mavenscanner, self-closed forms included. The vendored row (build_repo_edit) is the next checklist item of the tracking issue #715.
Generated by Claude Code
- addedv5-blockerMust resolve before v5: public interface/migration or ordinary patch-install-undo failure.Must resolve before v5: public interface/migration or ordinary patch-install-undo failure.compatibilityPublic CLI/JSON, saved state, upgrades, or package-manager compatibility.Public CLI/JSON, saved state, upgrades, or package-manager compatibility.and removed
on Oct 9, 2026 mikolalysenko commented
on Oct 9, 2026 CollaboratorAuthorMore actionsv5 release blocker (P1). Ordinary self-closing/commented Maven XML must not acquire duplicate repositories/dependencyManagement sections after a first patch.
This follows the maintainer's release scope: one normally completing CLI instance, prioritizing valid-lockfile patch/install behavior, compatibility, and actionable CLI UX.
mikolalysenko commented
on Oct 9, 2026 CollaboratorAuthorMore actions[agent] Claiming for v5 blocker burn-down (shared root cause: hosted Maven pom rewriter locates // with raw text anchors instead of the scope-aware formats::maven scanner). Branch: agent/v5-maven-pom-scope. Claim-ID: 20261009T164149Z-a78ef2
- added a commit that references this issue
on Oct 9, 2026
[agent] Found by the scheduled Maven bug-hunt routine (ledger #318).
Summary
The hosted rewriter (
scan --mode hosted) and the vendored wiring (vendor) each look for an existing section by an exact text pattern. When that pattern doesn't match, they write a brand-new section before</project>, even though the pom already has one. Maven's pom reader rejects the result withNon-parseable POM … Duplicated tag, so nothing builds. Meanwhile socket-patch exits 0, reportsredirected: 1/applied: 1with no warning, andvexattestsnot_affected.Three ordinary pom shapes trigger it:
<repositories/>(self-closed, empty)insert_maven_repositorycheckspom.contains("<repositories>")<repositories>before</project><repositories/>build_repo_editanchors on</repositories><repositories><dependencyManagement>with an XML comment before<dependencies>(e.g.<!-- versions shared across the org -->), and the patched GA is transitive(?s)<dependencyManagement>\s*<dependencies>allows only whitespace between the tags<dependencyManagement><dependencyManagement/>, patched GA transitive<dependencyManagement>This is a different mechanism from #259, where edits land inside comments or profiles. Here the anchor is missed entirely and a duplicate top-level element is created. Masking comments, as #259 suggests, would not fix the self-closed shapes, and would only fix the comment shape if the regex is also changed.
Impact
scan/vendor.vexboth claim the patch is in effect:vex --no-verifyemitsnot_affectedfor the hosted case, andvex --offlinedoes the same for the vendored case.Repro
Setup:
socket-patch 4.0.0built from mainf6b7fb9, and real Apache Maven. For hosted, a local stub API serves the same grant, patched jar and served pom ascrates/socket-patch-cli/tests/e2e_redirect_maven_build.rs(commons-text 1.10.0 →1.10.0-socket.4d5e6f70), and asettings.xmlmirror mapssocket-patch-<uuid>onto the stub. For vendored, a hand-staged.socket/manifest.json+ blob is used, as ine2e_vendor_maven_build.rs.Hosted, comment inside
<dependencyManagement>(commons-text arrives transitively via commons-configuration2 2.9.0):Self-closed repositories, hosted or vendored (a direct
commons-text:1.10.0dependency):Control: the same poms without the self-closed tag or the comment are rewritten in place and resolve the patched jar (
PATCHED commons-text-1.10.0-socket.4d5e6f70.jar, and for vendoredPATCHED commons-text-1.10.0.jar).Expected vs actual
file://repository wired into the project pom. If the tool can't find a safe anchor, it should expand the self-closed element, or refuse with a warning instead of reportingredirected/applied.Matrix (Linux, JDK 21; each cell run twice on fresh copies)
<repositories/><dependencyManagement><dependencyManagement/><repositories/>macOS and Windows weren't probed. The rewrite is pure text, so it doesn't depend on the OS.
Suspect code (main
f6b7fb9)crates/socket-patch-core/src/patch/redirect/mod.rs:7007:insert_maven_repositoryusespom.contains("<repositories>"), else a new section before</project>(line 7011).crates/socket-patch-core/src/patch/redirect/mod.rs:7028: theinsert_maven_dependency_managementregex(?s)<dependencyManagement>\s*<dependencies>, else a new section (line 7037).crates/socket-patch-core/src/vendor/maven_repo.rs:1115:build_repo_editanchors only on</repositories>, then falls back to a new section before</project>(line 1117).Related, but a different mechanism: #259 (edits landing in comments/profiles/plugins) and #260 (redirect confirmed by substring, which is why
vexaccepts these poms).