Skip to content

Improve unresolved plugin dependency diagnostics - #15995

Merged
jdaugherty merged 4 commits into
8.0.xfrom
fix/plugin-dependency-diagnostics
Sep 23, 2026
Merged

jdaugherty merged 4 commits into
8.0.xfrom
fix/plugin-dependency-diagnostics

Conversation

@jamesfredley

Copy link
Copy Markdown
Contributor

Summary

  • replace the malformed single-line ERROR for an unresolved plugin with one concise WARN
  • enumerate each missing or version-incompatible dependency with required and actual versions
  • reuse existing resolution rules; no change to discovery, registration, failed-plugin tracking, or load order

Verification

  • :grails-core:test --tests PluginDiscoverySpec
  • :grails-core:test
  • git diff --check

This is an AI-generated starting point for richer plugin dependency diagnostics.

Assisted-by: opencode:gpt-5.6-sol

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves Grails plugin discovery diagnostics by replacing a malformed unresolved-dependency ERROR with a single WARN that enumerates which plugin dependencies are missing or version-incompatible, without changing the underlying plugin discovery/registration rules.

Changes:

  • Replace the previous unresolved-plugin ERROR log with a WARN emitted when delayed plugins ultimately fail to resolve.
  • Add detailed per-dependency messages indicating “missing” vs “version mismatch” (required vs actual).
  • Add a Spock spec asserting the new WARN content and that no stack trace is printed at normal verbosity.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
grails-core/src/main/groovy/org/apache/grails/core/plugins/DefaultPluginDiscovery.java Introduces logUnresolvedDependencies() to emit a single detailed WARN for plugins that fail dependency resolution.
grails-core/src/test/groovy/org/apache/grails/core/plugins/PluginDiscoverySpec.groovy Adds a test to validate the new unresolved dependency WARN format and content.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +427 to +449
private void logUnresolvedDependencies(PluginInfo plugin) {
var unresolvedDependencies = new ArrayList<String>();
for (var name : plugin.getDependsOnNames()) {
var requiredVersion = plugin.getMetadata().getDependentVersion(name);
var dependency = findPlugin(name);
if (dependency == null) {
unresolvedDependencies.add(
"dependency [" + name + "] with required version [" + requiredVersion + "] is missing"
);
} else if (!GrailsVersionUtils.isValidVersion(dependency.getPluginVersion(), requiredVersion)) {
unresolvedDependencies.add(
"dependency [" + name + "] has version [" + dependency.getPluginVersion() +
"] but requires [" + requiredVersion + "]"
);
}
}
LOG.warn(
"Grails plug-in [{}] with version [{}] cannot be loaded: {}",
plugin.getName(),
plugin.getPluginVersion(),
String.join("; ", unresolvedDependencies)
);
}
@bito-code-review

Copy link
Copy Markdown

The suggestion to improve logUnresolvedDependencies() by checking delayedLoadPlugins and failedPlugins is valid and would enhance the accuracy of the dependency resolution warnings. Currently, the method only uses findPlugin(name), which returns null if a plugin is not registered, causing it to be incorrectly classified as "missing" even if it exists but failed to load or is delayed.

To implement this, you can update the logic to check these collections before defaulting to the "missing" classification:

private void logUnresolvedDependencies(PluginInfo plugin) {
    var unresolvedDependencies = new ArrayList<String>();
    for (var name : plugin.getDependsOnNames()) {
        var requiredVersion = plugin.getMetadata().getDependentVersion(name);
        var dependency = findPlugin(name);
        
        if (dependency == null) {
            // Check if it exists in failed or delayed collections
            if (failedPlugins.containsKey(name)) {
                unresolvedDependencies.add("dependency [" + name + "] failed to load");
            } else if (delayedLoadPlugins.stream().anyMatch(p -> p.getName().equals(name))) {
                unresolvedDependencies.add("dependency [" + name + "] is delayed");
            } else {
                unresolvedDependencies.add("dependency [" + name + "] with required version [" + requiredVersion + "] is missing");
            }
        } else if (!GrailsVersionUtils.isValidVersion(dependency.getPluginVersion(), requiredVersion)) {
            unresolvedDependencies.add("dependency [" + name + "] has version [" + dependency.getPluginVersion() + "] but requires [" + requiredVersion + "]");
        }
    }
    // ... log warning
}

grails-core/src/main/groovy/org/apache/grails/core/plugins/DefaultPluginDiscovery.java

if (dependency == null) {
            // Check if it exists in failed or delayed collections
            if (failedPlugins.containsKey(name)) {
                unresolvedDependencies.add("dependency [" + name + "] failed to load");
            } else if (delayedLoadPlugins.stream().anyMatch(p -> p.getName().equals(name))) {
                unresolvedDependencies.add("dependency [" + name + "] is delayed");
            } else {
                unresolvedDependencies.add("dependency [" + name + "] with required version [" + requiredVersion + "] is missing");
            }
        } else if (!GrailsVersionUtils.isValidVersion(dependency.getPluginVersion(), requiredVersion)) {

@codecov

codecov Bot commented Jul 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.4432%. Comparing base (1cce663) to head (3b3464e).
⚠️ Report is 20 commits behind head on 8.0.x.

Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##                8.0.x     #15995        +/-   ##
==================================================
+ Coverage     57.4112%   57.4432%   +0.0320%     
- Complexity      22539      22557        +18     
==================================================
  Files            2129       2129                
  Lines          103816     103840        +24     
  Branches        18638      18646         +8     
==================================================
+ Hits            59602      59649        +47     
+ Misses          35954      35932        -22     
+ Partials         8260       8259         -1     
Files with missing lines Coverage Δ
...he/grails/core/plugins/DefaultPluginDiscovery.java 65.6357% <100.0000%> (+4.2125%) ⬆️

... and 8 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@davydotcom davydotcom left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good — approving.

Failure determination is unchanged: plugins still fail the same way via the existing dependency resolution / delayed-load path into failedPlugins. Discovery, registration, failed-plugin tracking, and load order are untouched.

What’s new here is the notification: replacing the malformed ERROR with a single concise WARN that enumerates missing vs version-incompatible dependencies. That’s a clearer alert for users without changing how unresolved plugins are decided.

);
}
}
LOG.warn(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I disagree on this being a warning, there is a legitimate configuration issue. This should be an error message

@davydotcom davydotcom left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Revising my earlier approval with one requested change.

The richer diagnostics look good, and failure determination is still unchanged — this is still just a clearer alert for an already-failed plugin. Please keep the log level at ERROR, not WARN.

The previous message was already LOG.error. Downgrading to WARN isn’t justified in the PR beyond “one concise WARN,” and unresolved/failed plugin dependencies are a real load failure. ERROR keeps the severity aligned with that outcome and with prior behavior; WARN can be filtered out of environments that only surface errors.

Requested change:

  • use LOG.error(...) in logUnresolvedDependencies
  • update the new PluginDiscoverySpec assertion accordingly (ERROR instead of WARN)

);
}
}
LOG.warn(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please keep this at ERROR rather than WARN.

Unresolved dependencies already put the plugin in failedPlugins; that is a load failure, and the previous code logged it with LOG.error. A clearer message is welcome, but the severity should stay ERROR so it isn’t lost when WARN is filtered.

@jamesfredley jamesfredley moved this to Todo in Apache Grails Jul 24, 2026
- Revert the unresolved-dependency log from WARN back to ERROR, per
  jdaugherty and davydotcom (davydotcom revised an initial approval to
  CHANGES_REQUESTED specifically for this): unresolved dependencies are
  a real load failure - the plugin already lands in failedPlugins - and
  the prior code logged it at ERROR. WARN risked being filtered out of
  environments that only surface errors.
- Fix logUnresolvedDependencies() misclassifying a dependency as
  "missing" whenever it isn't yet registered, even when the dependency
  plugin actually exists but itself failed to load or is still waiting
  in the delayed-load queue (flagged independently by Copilot's inline
  review and bito-code-review's bot comment; verified by tracing
  loadDelayedPlugins()'s processing order). Now distinguishes three
  cases: registered with an incompatible version (unchanged), found in
  failedPlugins ("failed to load"), found in delayedLoadPlugins ("is
  still pending load"), and only "is missing" when none of the above.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@borinquenkid borinquenkid added this to the grails:8.0.0-RC1 milestone Jul 27, 2026
@testlens-app

This comment has been minimized.

…ing versions

- Rewrite the new PluginDiscoverySpec features on the LogCapture test
  fixture. They captured System.err expecting slf4j-simple output, but
  8.0.x now routes DefaultPluginDiscovery logging through logback, so
  both features failed once merged with the base branch.
- Include the version that was found when an unresolved dependency is
  still pending load. A plugin only gives up on a pending dependency when
  no delayed candidate satisfies its version constraint, so the previous
  message hid the actual cause; add a feature covering that path.
@jdaugherty

Copy link
Copy Markdown
Contributor

Reviewed the branch against current 8.0.x and pushed two follow-up commits (a merge of 8.0.x plus a fix) so this can go in.

What was wrong

  • The log level is already back at ERROR from the earlier feedback, and that stays. Both new spec features failed once merged with 8.0.x, though: they captured System.err expecting slf4j-simple output, but DefaultPluginDiscovery logging now goes through logback on the base branch, so the capture saw nothing (errors.size() == 1 failed with [], and the second feature hit an NPE on a null line).
  • The is still pending load branch hid the real cause. A plugin only fails while a same-named dependency is still delayed when that delayed candidate does not satisfy the version constraint (isDependentOn checks name and version before re-queuing). So the message reported the dependency as merely pending, when the actual problem was the version.

What changed

  • Rewrote both features on the existing LogCapture test fixture and assert on Level.ERROR plus the formatted message, matching the neighbouring duplicate-registration test.
  • isDelayed(name) became findDelayedPlugin(name), and the message now reads dependency [x] with required version [2.0.0] is still pending load and only version [1.0.0] was found. Added a feature that drives that path (dependent processed before its too-old, still-delayed dependency gives up).

Verification

  • :grails-core:test full module: 657 tests, 0 failures
  • :grails-core:codeStyle clean

@jdaugherty

Copy link
Copy Markdown
Contributor

The original issue has been addressed, so merging.

@jdaugherty
jdaugherty merged commit bba0e9c into 8.0.x Sep 23, 2026
80 checks passed
@jdaugherty
jdaugherty deleted the fix/plugin-dependency-diagnostics branch September 23, 2026 23:32
@github-project-automation github-project-automation Bot moved this from Todo to Done in Apache Grails Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants