Skip to content

fix: backward-compatible validation for old lockfiles#1573

Draft
algomaster99 wants to merge 12 commits into
mainfrom
fix/backward-compat-validate
Draft

fix: backward-compatible validation for old lockfiles#1573
algomaster99 wants to merge 12 commits into
mainfrom
fix/backward-compat-validate

Conversation

@algomaster99
Copy link
Copy Markdown
Member

@algomaster99 algomaster99 commented May 16, 2026

The changes fix backward-compatible validation for lockfiles generated by older plugin versions. This will also fix #1562.

Problem

Validating a lockfile generated by an older plugin version with the current plugin (5.16.0) fails with a validation error, even though the project's dependencies haven't changed. The root cause is that 5.16.0 added three new fields to the lockfile format:

  • parentPom on each dependency node and plugin
  • parentPom chains on BOM Pom objects
  • mavenExtensions on the lockfile root

Solution

6 flags are added:

  1. includeBoms
  2. includeParentPom
  3. includeMavenExtensions
  4. allowBomValidationFailure
  5. allowParentPomValidationFailure
  6. allowMavenExtensionsValidationFailure

Now, old lockfiles lack includeParentPom so the validation will now skip comparing parentPom comparison. allowParentPomValidationFailure need not be specified. allowParentPomValidationFailure is only needed when includeParentPom is true.

ToDo:

@algomaster99
Copy link
Copy Markdown
Member Author

@copilot resolve the merge conflicts in this pull request

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 1, 2026

@copilot resolve the merge conflicts in this pull request

Resolved. I merged origin/main, fixed the conflict in AbstractLockfileMojo, and committed it in 9bf3c9d.

algomaster99 and others added 4 commits June 1, 2026 13:43
…parentPom/extensions

Add 6 explicit Config flags (includeBoms, includeParentPom, includeMavenExtensions,
allowBomValidationFailure, allowParentPomValidationFailure,
allowMavenExtensionsValidationFailure) following the existing includeEnvironment /
allowEnvironmentalValidationFailure pattern.

Backward compat is automatic: old lockfiles lack these fields in JSON so Gson
deserialises all include* as false, causing all three optional comparisons to be
skipped. New lockfiles store include*=true and all comparisons are enabled.

ValidateChecksumMojo now uses a 4-phase comparison driven by Config flags instead of
heuristic auto-detection (lockFileHasParentPomData, lockFileHasNodeBomData etc.).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@algomaster99 algomaster99 force-pushed the fix/backward-compat-validate branch from a9e0093 to 1de1dca Compare June 1, 2026 11:52
algomaster99 and others added 5 commits June 1, 2026 13:55
Config gained boms/parentPom/extensions fields in 5bfa33f; the test's
storedConfig() helper still called the old 9-arg constructor, breaking
test-compile.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… fixture

After the refactor to explicit Config flags (5bfa33f), validation gates on
config.isIncludeMavenExtensions(). The old fixture lacked this field so Gson
defaulted it to false, skipping extension checksum validation and causing the
test to pass instead of fail.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The pom.xml was setting includeMavenPlugins=true, but the stored lockfile
had mavenPlugins=[]. This caused Phase 1 (plugin equality) to fail before
Phase 4 (extension checksum) was reached, so the build failed without
printing "Missing extensions" in stdout.

Setting includeMavenPlugins=false in both pom.xml and the lockfile config
lets Phase 1 pass and Phase 4 correctly detect the tampered extension checksum.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Member Author

@algomaster99 algomaster99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot can you take care of the reviews.

Comment on lines +67 to +77
@Parameter(property = "includeParentPom")
protected String includeParentPom;

@Parameter(property = "allowParentPomValidationFailure")
protected String allowParentPomValidationFailure;

@Parameter(property = "includeMavenExtensions")
protected String includeMavenExtensions;

@Parameter(property = "allowMavenExtensionsValidationFailure")
protected String allowMavenExtensionsValidationFailure;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be Boolean like others.

],
"metaData": {
"config": {
"includeMavenPlugins": true,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is wrong with keeping it true?

@algomaster99
Copy link
Copy Markdown
Member Author

@copilot can you take care of the reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Option to ignore parentPom and extensions

2 participants