Skip to content

Show the GAV being searched for in DependencyInsight's instance name - #200

Merged
jkschneider merged 1 commit into
mainfrom
dependency-insight-instance-name
Oct 1, 2026
Merged

jkschneider merged 1 commit into
mainfrom
dependency-insight-instance-name

Conversation

@jkschneider

@jkschneider jkschneider commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

What's wrong

DependencyInsight renders in recipe lists as a bare "Dependency insight for Gradle and Maven", with no indication of what it is actually searching for. Two runs looking for completely different dependencies are indistinguishable.

That isn't an accident of the UI — it falls out of Recipe.getInstanceName(), which only appends a value when a recipe has exactly one required option:

List<OptionDescriptor> options = new ArrayList<>(getOptionDescriptors());
options.removeIf(opt -> !opt.isRequired());
if (options.isEmpty()) {
    return getDisplayName();
}
if (options.size() == 1) {
    // ... displayName + " `" + value + "`"
}
return getDisplayName();

DependencyInsight has two required options, groupIdPattern and artifactIdPattern, so it falls through to the plain display name every time, however it was configured.

The change

Override getInstanceNameSuffix() so the GAV being searched for is always part of the name:

configuration instance name
com.fasterxml.jackson* / jackson-* Dependency insight for Gradle and Maven `com.fasterxml.jackson*:jackson-*`
the same, plus version 2.x Dependency insight for Gradle and Maven `com.fasterxml.jackson*:jackson-*:2.x`
unconfigured Dependency insight for Gradle and Maven

version is included only when set, since it defaults to searching all versions. scope is deliberately left out — it narrows the search rather than identifying what is being searched for.

On the null guard

The suffix returns "" when either pattern is null, which is worth calling out because the obvious implementation gets this wrong.

Both patterns are required options, so they are non-null in any valid configuration. But getInstanceName() is also called on the descriptor of an unconfigured recipe, where every option is null — that is what gets rendered in a recipe catalog or marketplace listing. An unguarded String.format("%s:%s", groupIdPattern, artifactIdPattern) produces "Dependency insight for Gradle and Maven null:null" there.

  • This is not hypothetical: it is how moderneinc/moderne-saas#1841 was diagnosed, where an unguarded suffix on another recipe rendered as `null:null:null`. Returning "" keeps the blank-suffix path in getInstanceName(), which falls back to the display name.

ChangeDependency.getInstanceNameSuffix() in this repo has the same unguarded shape and will render `null:null` for an unconfigured descriptor. I have left it alone to keep this PR to one recipe — happy to fix it here or in a follow-up, whichever you prefer.

Tests

Three cases in DependencyInsightTest: the GAV suffix, the version-included variant, and the unconfigured descriptor falling back to the display name.

DependencyInsight has two required options, so Recipe.getInstanceName()'s
single-required-option rule never fires and every run renders as the bare
display name. Override getInstanceNameSuffix() to always carry the group
and artifact patterns, plus the version when one is set.

The suffix is empty when the patterns are null, which is the case when the
descriptor of an unconfigured recipe is rendered in a catalog; an unguarded
format string shows `null:null` there.
@jkschneider
jkschneider merged commit 36b3c6e into main Oct 1, 2026
1 check passed
@jkschneider
jkschneider deleted the dependency-insight-instance-name branch October 1, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant