Skip to content

Improve error diagnostics when publisher lookup fails - #266

Merged
cstamas merged 6 commits into
maveniverse:mainfrom
laeubi:issue-265
Jun 18, 2026
Merged

cstamas merged 6 commits into
maveniverse:mainfrom
laeubi:issue-265

Conversation

@laeubi

@laeubi laeubi commented Jan 24, 2026 •

Copy link
Copy Markdown
Contributor

Enhanced error message to include:

  • List of available publishers
  • List of server IDs with publisher configuration
  • Hint about checking settings.xml or using -Dpublisher parameter
  • Added test to verify error message contains helpful information

Fixes #265

@cstamas what do you think?

Summary by CodeRabbit

Release Notes

  • Bug Fixes & Improvements
    • Enhanced error messages for publisher configuration failures with diagnostic information about available publishers and server configurations, providing clearer guidance to troubleshoot settings.
    • Improved logging visibility when resolving publisher names.

Enhanced error message to include:
- List of available publishers
- List of server IDs with publisher configuration
- Hint about checking settings.xml or using -Dpublisher parameter
- Added test to verify error message contains helpful information

Fixes maveniverse#265
@laeubi
laeubi requested a review from cstamas January 24, 2026 10:09
@cstamas

cstamas commented Jan 26, 2026

Copy link
Copy Markdown
Member

Looks ok, but this is why I created mvn njord:status that should tell ahead of release attempt is everything set up correctly... @kwin any opinion?

@cstamas

cstamas commented Jan 26, 2026

Copy link
Copy Markdown
Member

Example of njord:status on unconfigured (not using) njord and on a fully configured project:
https://gist.github.com/cstamas/3e53609b1a554f494afc473912a632f6

}
}

logger.error("Server IDs with publisher configuration:");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is confusing, you can configure the publisher also via project properties, not only via settings.xml (https://maveniverse.eu/docs/njord/configuration/).

@cstamas

cstamas commented Jan 26, 2026 •

Copy link
Copy Markdown
Member

The "superpowers" of Njord comes from:

  • it can locally stage (create and deploy into store) any project, even projects never heard about Njord, as gist above shows, I can take any project, check out a release tag, and do mvn deploy -P apache-release -DaltDeploymentRepository=id::njord: and I will end up with given project locally staged
  • I can operate on stores (locally staged artifacts) by multiple ops, like validate them, export/import them, or by publishing them. Again, Njord allows me to pass (and override) all parameters as user properties even if project itself was Njord unaware.

Users of "fast lane" (autoPublish) are actually just coalescing these two steps above (locally stage + publish) into one (where publish happen at end of Maven session). So it is merely a "convenience", allows users to fast-lane to getting things onto Central (or wherever they want). Several teams do not "fast lane": for example Jetty team publishes to two places (central and their own repo), Quarkus performs validation (not happening with fast lane) and do much more after publishing (they use check-artifacts-availability to make sure what they staged locally, validated then published is truly available from publishing target), etc

@coderabbitai

coderabbitai Bot commented Jun 18, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@cstamas, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 46 minutes. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c48b122c-d57a-49e8-a9fb-2484dca2d5e8

📥 Commits

Reviewing files that changed from the base of the PR and between d9f6651 and c3ce52b.

📒 Files selected for processing (1)
  • core/src/main/java/eu/maveniverse/maven/njord/shared/impl/publisher/DefaultArtifactPublisherRedirector.java
📝 Walkthrough

Walkthrough

DefaultArtifactPublisherRedirector replaces the bare IllegalArgumentException thrown on unresolved publisher names with a new private helper dumpPublisherDiagAndThrow, which logs available publisher names and relevant server configurations before throwing with a settings.xml guidance message. A fallback log is also promoted from debug to logger.info. A new test verifies the exception message content.

Publisher resolution diagnostics

Layer / File(s) Summary
Diagnostic helper and error path
core/src/main/java/eu/maveniverse/maven/njord/shared/impl/publisher/DefaultArtifactPublisherRedirector.java
New imports (ArrayList, Comparator, TreeMap) support the new dumpPublisherDiagAndThrow helper. The unresolved-name throw is replaced by a call to that helper, which sorts and logs available publishers and server IDs with publisher/redirect config before throwing an IllegalArgumentException carrying a settings.xml guidance message. The fallback derivation log is promoted to logger.info.
Error message test
core/src/test/java/eu/maveniverse/maven/njord/shared/impl/publisher/DefaultArtifactPublisherRedirectorTest.java
Adds unconfiguredPublisherProvidesHelpfulMessage, asserting that calling getArtifactStorePublisherName("unconfigured") throws IllegalArgumentException with substrings covering the lookup name, a check-logs instruction, and a settings.xml reference.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 When your publisher name goes astray,
No more cryptic silence today!
I sorted the list, checked each server ID,
And pointed the way to your settings.xml guide.
Hop along, the error message now says what's true! 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: improving error diagnostics when publisher lookup fails, which is the core focus of the PR.
Linked Issues check ✅ Passed The PR fully addresses issue #265 by implementing enhanced error diagnostics that display available publishers, server IDs with publisher configuration, and helpful guidance directing users to settings.xml, directly resolving the reported problem.
Out of Scope Changes check ✅ Passed All changes are directly in scope: enhanced error messages in DefaultArtifactPublisherRedirector and a new test verifying the diagnostic output, with no unrelated modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cstamas

cstamas commented Jun 18, 2026

Copy link
Copy Markdown
Member

The message now looks like this (trying publish with non existed publisher):

$ mvn njord:0.9.8-SNAPSHOT:publish -Dnjord.publisher=foo -Dnjord.store=jbang-maven-plugin-00001
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] 
[INFO] --- njord:0.9.8-SNAPSHOT:publish (default-cli) @ standalone-pom ---
[INFO] Njord 0.9.8-SNAPSHOT session created
[INFO] Found one store, using it: 'jbang-maven-plugin-00001'
[ERROR] Failed to resolve publisher name 'foo'
[ERROR] Available publishers:
[ERROR]   - apache-rao
[ERROR]   - black-hole
[ERROR]   - deploy
[ERROR]   - install
[ERROR]   - sonatype-cp
[ERROR]   - sonatype-nx2
[ERROR]   - sonatype-nx3
[ERROR] Available server IDs with publisher configured (can also be set via project properties):
[ERROR]   - bad-jline-publish (redirected to: not-sonatype-central-portal) -> MISSING
[ERROR]   - jline-publish (redirected to: sonatype-central-portal) -> FOUND
[ERROR]   - oss.sonatype.org (publisher: sonatype-cp)
[ERROR]   - s01.oss.sonatype.org (publisher: sonatype-cp)
[ERROR]   - sonatype-central-portal (publisher: sonatype-cp)
[ERROR]   - sonatype-cp-service (publisher: sonatype-cp)
[ERROR]   - sonatype-other-central-portal (redirected to: sonatype-central-portal) -> FOUND
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.252 s
[INFO] Finished at: 2026-06-18T14:33:28+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal eu.maveniverse.maven.plugins:njord:0.9.8-SNAPSHOT:publish (default-cli) on project standalone-pom: Execution default-cli of goal eu.maveniverse.maven.plugins:njord:0.9.8-SNAPSHOT:publish failed: Failed to resolve publisher name 'foo'. Check the logs for available publishers and server configurations, or verify your settings.xml configuration -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
$ 

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
core/src/main/java/eu/maveniverse/maven/njord/shared/impl/publisher/DefaultArtifactPublisherRedirector.java (1)

252-254: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Include CLI/property guidance in the thrown hint.

Line 252-Line 254 still only points users to settings.xml; this misses the explicit remediation path via publisher property/-Dpublisher that the issue/PR objective calls out. Please include that in the exception text so users can recover without digging further.

Suggested patch
-        throw new IllegalArgumentException("Failed to resolve publisher name '" + name
-                + "'. Check the logs for available publishers and server configurations, "
-                + "or verify your settings.xml configuration");
+        throw new IllegalArgumentException("Failed to resolve publisher name '" + name
+                + "'. Check the logs for available publishers and server configurations, "
+                + "and verify your settings.xml or set publisher explicitly via -Dnjord.publisher=<name>");
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@core/src/main/java/eu/maveniverse/maven/njord/shared/impl/publisher/DefaultArtifactPublisherRedirector.java`
around lines 252 - 254, The exception message thrown in the
DefaultArtifactPublisherRedirector class when failing to resolve publisher name
only mentions checking settings.xml configuration but does not include the
CLI/property remediation path. Update the IllegalArgumentException message to
additionally mention that users can specify the publisher directly using the
-Dpublisher property or CLI flag, providing a more complete and actionable error
message that helps users recover without additional investigation.
🧹 Nitpick comments (1)
core/src/test/java/eu/maveniverse/maven/njord/shared/impl/publisher/DefaultArtifactPublisherRedirectorTest.java (1)

110-117: ⚡ Quick win

Assert the explicit publisher override hint to prevent regressions.

To fully protect the diagnostic contract, add an assertion for the property/CLI recovery path (for example -Dnjord.publisher).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@core/src/test/java/eu/maveniverse/maven/njord/shared/impl/publisher/DefaultArtifactPublisherRedirectorTest.java`
around lines 110 - 117, The test assertions in
DefaultArtifactPublisherRedirectorTest are missing a check for the explicit
publisher override hint that provides users with a recovery path. Add an
additional Assertions.assertTrue call after the existing message content checks
to verify that the error message contains the publisher override property or CLI
option (such as -Dnjord.publisher) to prevent regressions and ensure the
diagnostic contract fully includes recovery guidance.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In
`@core/src/main/java/eu/maveniverse/maven/njord/shared/impl/publisher/DefaultArtifactPublisherRedirector.java`:
- Around line 252-254: The exception message thrown in the
DefaultArtifactPublisherRedirector class when failing to resolve publisher name
only mentions checking settings.xml configuration but does not include the
CLI/property remediation path. Update the IllegalArgumentException message to
additionally mention that users can specify the publisher directly using the
-Dpublisher property or CLI flag, providing a more complete and actionable error
message that helps users recover without additional investigation.

---

Nitpick comments:
In
`@core/src/test/java/eu/maveniverse/maven/njord/shared/impl/publisher/DefaultArtifactPublisherRedirectorTest.java`:
- Around line 110-117: The test assertions in
DefaultArtifactPublisherRedirectorTest are missing a check for the explicit
publisher override hint that provides users with a recovery path. Add an
additional Assertions.assertTrue call after the existing message content checks
to verify that the error message contains the publisher override property or CLI
option (such as -Dnjord.publisher) to prevent regressions and ensure the
diagnostic contract fully includes recovery guidance.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 92802521-576b-48da-8b56-8b6c5840b733

📥 Commits

Reviewing files that changed from the base of the PR and between 9d4cffe and d9f6651.

📒 Files selected for processing (2)
  • core/src/main/java/eu/maveniverse/maven/njord/shared/impl/publisher/DefaultArtifactPublisherRedirector.java
  • core/src/test/java/eu/maveniverse/maven/njord/shared/impl/publisher/DefaultArtifactPublisherRedirectorTest.java

@cstamas
cstamas merged commit 3d0e5d7 into maveniverse:main Jun 18, 2026
2 checks passed
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.

Name '${forgeSnapshotId}' is not a name of known publisher nor is server ID with configured publisher

4 participants