Repository navigation
Fix maven.config user property parsing (#535, #550) - #1754
Conversation
Assisted-by: Claude Code:claude-opus-5-5
Vendoring a Maven reactor reads user properties from .mvn/maven.config
so an override there beats a pom <properties> value. The reader split
the whole file on whitespace and kept only -Dk=v tokens, so it:
- used properties from commented-out "#" lines, which Maven 3.9+
ignores, and
- missed --define=k=v and "-D k=v" (or -D and k=v on separate lines),
which Maven applies.
Either way vendor could rewrite a ${prop} dependency to the patched
base, silently downgrading the build (and vex then attested it), or
refuse a patch that should apply. Comment lines are now skipped, every
-D/--define spelling is read, and -Dk sets k=true as in Maven.
Fixes #535, #550.
Assisted-by: Claude Code:claude-opus-5-5
Maven 3.9+ reads each maven.config line as one argument. Follow that: the value of -Dk=v is the rest of the line (so "-Dv=1.0 # note" is not 1.0), a wholly quoted argument is unquoted, trimming matches Java's String.trim, and a bare -D never swallows the next option. Assisted-by: Claude Code:claude-opus-5-5
|
BugBot review Generated by Claude Code |
|
Burn-down agent: labeled Ready for review at head
Generated by Claude Code |
|
Final reviewer: pushed Removed Generated by Claude Code |
Maven before 3.9 splits .mvn/maven.config on whitespace, so a line like `-B -Dct.version=1.11.0` or `-Dfoo=1 -Dct.version=1.11.0` defines ct.version there. The old reader caught those tokens; the per-line reader dropped them, which let the planner rewrite a pom to the patched base while a Maven 3.6/3.8 build applies the override. Add any `-Dk=v` token from a whitespace split of the non-comment lines that the per-line reading did not define. Recognising an override that Maven 3.9 would not apply only makes the planner refuse to pin, so this stays fail-closed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeRoPDBr4nQsvdEk3uV
|
bugbot run Generated by Claude Code |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 0548a33. Configure here.
|
Burn-down agent: labeled Ready for review at head
Generated by Claude Code |
Final review briefWhat it does. When socket-patch vendors a Maven reactor, it reads user properties from Risk: low. The change is one pure function plus tests. The extra pre-3.9 reading can only add overrides, and an extra override makes the planner refuse to pin ( Look here
Verified
Changes I made: none in this pass. The earlier final-reviewer pass pushed Open questions: none. Auto-merge (squash) is armed, so approving sends this PR straight to the merge queue. Generated by Claude Code |
LLM Description written by Claude Code:claude-opus-5-5
Fixes #535
Fixes #550
Summary
When it vendors a Maven reactor, socket-patch reads user properties from
.mvn/maven.configso that an override there beats a pom<properties>value, as it does in Maven. The reader misread the file in two ways,
and each one can silently downgrade the build to the patched base, after
which
vendor --checkandvexboth confirm the downgrade:#lines, which Maven3.9+ ignores.
--define=k=v,-D k=v, and-Dwithk=vonthe next line, all of which Maven applies.
Root cause
cli_properties(crates/socket-patch-core/src/vendor/jvm/maven_reactor.rs)split the whole file on whitespace and kept only tokens shaped
-Dk=v.It never dropped comment lines and knew no other spelling.
Fix
cli_propertiesnow reads the file the way Maven 3.9+ does:#lines skipped;-Dk=v,-D k=v,--define=k=vand--define k=vall define aproperty, and so does a bare
-D/--definefollowed by ak=vline (a bare
-Dnever takes the next option as its value);-Dct.version=1.10.0 # TODOis not 1.10.0;
-Dksetsk=true, a laterdefinition wins, and trimming matches Java's
String.trim.Every caller (vendor,
vendor --check, vex) goes through the sameplanner, so all of them pick this up. Older Maven (before 3.9) rejects
#lines itself, and recognising an override that it would not applyonly makes the planner refuse to pin (
conflicting_literal_version), sothe planner never claims a patch the build does not link.
Test evidence
maven_reactor::tests::maven_config_long_and_split_define_spellings_win(--define=,-D k=v,-D/--defineon their own line, CRLF, quoted, trailing text)${ct.version}rewritten to the patched base)maven_reactor::tests::maven_config_comment_lines_define_nothing(#,# … old pin, indented#,# just a note)maven_reactor::tests::maven_config_user_properties_parse_like_maven(parser table)Commands run locally (Linux, rustc 1.93.1):
cargo fmt --all -- --check: okcargo clippy --workspace --all-features -- -D warnings: okcargo test --workspace --all-features --no-fail-fast: 15077 passed,12 failed. The 12 failures come from this container, not this diff, and
are the same set Fix Go version gate ignoring go.work members (#1751) #1752 recorded: 9 write-failure tests that rely on
chmod blocking writes (the container runs as root), and 3 in
e2e_bun_lockb(local bun 1.4.4, CI pins 1.4.2). Every Maven/JVM testpasses.
the file, and the unit tests drive the same
planthatvendor,vendor --checkandvexrun.npm/,pypi/,gem/only dispatch to the binary)./code-review highfindings not fixedmerge_maven_config(the writer) matches only the-Dk=spelling ofits own two properties. If a user sets
maven.repo.local.tailoraether.offline.protocolswith--define=, vendor appends its ownline rather than extending theirs, and Maven then uses the later one.
That problem was there before this PR, is in a different function, and
fixing it needs new undo records, so it is left for a follow-up.
sbt::reactor_wiredlooks for the tail directory in the raw configtext, so a commented-out tail line counts as wiring. It was there
before this PR and is a separate shape-detection check, so it is left
for a follow-up.
https://claude.ai/code/session_011f9aeT7DJDAhBe2sDUWU8A
Note
Medium Risk
Changes how user properties from maven.config feed version/conflict resolution across vendor, check, and vex; wrong parsing could still mis-pin or over-refuse builds, but behavior is now aligned with Maven and heavily unit-tested.
Overview
Replaces naive whitespace tokenization of
.mvn/maven.configwith parsing that matches Maven 3.9+: one argument per line,#comments ignored, and support for--define, spaced-D k=v, and-D/--definewithk=von the next line. Values stay on the rest of the line (including trailing#text), quoted args are unquoted,-Dkmeansk=true, and later definitions win; a legacy pass still picks up pre-3.9-only-Dk=vtokens when the line parser did not set that key.That fixes the reactor planner treating commented pins as overrides (#550) and missing valid define spellings (#535), which could silently vendor to the patch base instead of refusing when a real override conflicts. New unit tests cover vendor behavior and a full
cli_propertiesfixture table.Reviewed by Cursor Bugbot for commit 0548a33. Configure here.
Generated by Claude Code