Skip to content

Suggest latest version in SymbolNotFound when no near matches#66

Merged
rochala merged 2 commits intomainfrom
worktree-issue-59
Apr 23, 2026
Merged

Suggest latest version in SymbolNotFound when no near matches#66
rochala merged 2 commits intomainfrom
worktree-issue-59

Conversation

@rochala
Copy link
Copy Markdown
Contributor

@rochala rochala commented Apr 23, 2026

Fixes #59.

Summary

  • In CellarError.SymbolNotFound.getMessage, when nearMatches is empty and the coordinate version is not already latest, appends a hint suggesting group:artifact:latest
  • Adds two tests: one verifying the hint appears for versioned coordinates, one verifying it is suppressed when already using latest

Test plan

  • ./mill lib.test passes (372/372)

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates CellarError.SymbolNotFound messaging to guide users toward using :latest when a symbol might exist only in newer artifact versions, aligning with the CLI/library support for the latest version sentinel.

Changes:

  • Append a Try 'group:artifact:latest'... hint when nearMatches is empty and the coordinate version isn’t already latest.
  • Add tests covering the hint being shown for versioned coordinates and suppressed for latest.

Reviewed changes

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

File Description
lib/src/cellar/CellarError.scala Adds the conditional “try :latest” hint to SymbolNotFound.getMessage when there are no near matches.
lib/test/src/cellar/CellarErrorTest.scala Adds unit tests to validate the new hint behavior for latest vs non-latest coordinates.

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

Comment on lines +29 to +32
if nearMatches.nonEmpty then s"$base Did you mean one of: ${nearMatches.mkString(", ")}?"
else if coord.version != "latest" then
s"$base\nTry '${coord.copy(version = "latest").render}' if the symbol was introduced in a newer version."
else base
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

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

The sentinel string "latest" is now duplicated here and in MavenCoordinate.resolveLatest. Consider centralizing it (e.g., MavenCoordinate.LatestVersion / coord.isLatest) so future changes to the sentinel don’t require hunting for string literals.

Copilot uses AI. Check for mistakes.
test("SymbolNotFound with empty nearMatches and version=latest does not add a Try hint"):
val latestCoord = MavenCoordinate("org.example", "lib", "latest")
val e = CellarError.SymbolNotFound("Foo", latestCoord, Nil)
assert(!e.getMessage.contains("Try"))
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

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

This assertion is very broad and could become flaky if the base message ever contains the word "Try" for other reasons. Consider asserting that the specific latest-version hint line (or the "Try 'org.example:lib:latest'" prefix) is absent instead.

Suggested change
assert(!e.getMessage.contains("Try"))
assert(!e.getMessage.contains("Try 'org.example:lib:latest'"))

Copilot uses AI. Check for mistakes.
@rochala rochala merged commit c74c675 into main Apr 23, 2026
5 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.

Suggest 'latest' version when SymbolNotFound with no near matches

2 participants