From c48877dcdd38eef75b6a85cf52d80d63cceca95b Mon Sep 17 00:00:00 2001 From: Kirtikumar Anandrao Ramchandani <33368817+KirtiRamchandani@users.noreply.github.com> Date: Fri, 20 Nov 2026 16:46:05 +0000 Subject: [PATCH] Fail clearly when Maven coordinates do not resolve Invalid coordinates previously produced an empty classpath and then IndexOutOfBoundsException from subList(0, artifacts.size()). Validate resolution up front and surface artifact problems instead. Fixes #1948 --- .../opensource/classpath/LinkageCheckerMain.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/dependencies/src/main/java/com/google/cloud/tools/opensource/classpath/LinkageCheckerMain.java b/dependencies/src/main/java/com/google/cloud/tools/opensource/classpath/LinkageCheckerMain.java index 834b872cd..55cc5d44e 100644 --- a/dependencies/src/main/java/com/google/cloud/tools/opensource/classpath/LinkageCheckerMain.java +++ b/dependencies/src/main/java/com/google/cloud/tools/opensource/classpath/LinkageCheckerMain.java @@ -156,6 +156,20 @@ private static Problems checkArtifacts( ImmutableList inputClassPath = classPathResult.getClassPath(); ImmutableList artifactProblems = ImmutableList.copyOf(classPathResult.getArtifactProblems()); + if (inputClassPath.size() < artifacts.size()) { + StringBuilder message = + new StringBuilder( + "Could not resolve all supplied Maven coordinates to a classpath. " + + "Resolved " + + inputClassPath.size() + + " of " + + artifacts.size() + + " artifacts."); + if (!artifactProblems.isEmpty()) { + message.append(" Problems: ").append(artifactProblems); + } + throw new IllegalArgumentException(message.toString()); + } ImmutableSet entryPoints = ImmutableSet.copyOf(inputClassPath.subList(0, artifacts.size()));