t8y2/dbx · error · IllegalArgumentException

Maven coordinate is required

Error message

Maven coordinate is required

What it means

DbxMavenResolver.parseCoordinate throws IllegalArgumentException when the Maven coordinate string is null, empty, or only whitespace. Coordinates are parsed by splitting on ':' and require at least 'group:artifact:version'. This fail-fast guard prevents ambiguous downstream artifact resolution errors.

Source

Thrown at plugins/jdbc/src/main/java/app/dbx/jdbc/maven/DbxMavenResolver.java:109

            artifacts.add(ResolvedArtifact.from(artifact, artifact.getFile()));
        }
        for (DependencyNode child : node.getChildren()) {
            collectRuntimeArtifacts(child, false, artifacts);
        }
    }

    private static boolean isRuntimeDependency(Dependency dependency) {
        if (dependency.isOptional()) {
            return false;
        }
        String scope = dependency.getScope();
        return scope == null || scope.isBlank() || JavaScopes.COMPILE.equals(scope) || JavaScopes.RUNTIME.equals(scope);
    }

    private static Artifact parseCoordinate(String coordinate) {
        String trimmed = coordinate == null ? "" : coordinate.trim();
        if (trimmed.isEmpty()) {
            throw new IllegalArgumentException("Maven coordinate is required");
        }
        String[] parts = trimmed.split(":");
        if (parts.length == 3) {
            return new DefaultArtifact(parts[0], parts[1], "", "jar", parts[2]);
        }
        if (parts.length == 4) {
            return new DefaultArtifact(parts[0], parts[1], parts[3], "jar", parts[2]);
        }
        if (parts.length == 5) {
            return new DefaultArtifact(parts[0], parts[1], parts[3], parts[2], parts[4]);
        }
        return new DefaultArtifact(trimmed);
    }

    private static String sha256(File file) throws Exception {
        MessageDigest digest = MessageDigest.getInstance("SHA-256");
        byte[] bytes = java.nio.file.Files.readAllBytes(file.toPath());
        byte[] hash = digest.digest(bytes);

View on GitHub (pinned to c0390bff16)

Solutions

  1. Pass a full Maven coordinate as a positional argument, e.g. com.example:foo:1.2.3
  2. Use the --coordinate/-c flag: --coordinate com.example:foo:1.2.3
  3. Fix the upstream variable in your script/CI so it is not empty before invoking the resolver

Example fix

// before
DbxMavenResolver resolver = new DbxMavenResolver(...);
resolver.rootArtifact(null);
// after
resolver.rootArtifact("com.example:foo:1.2.3");
Defensive patterns

Strategy: validation

Validate before calling

if (coordinate == null || coordinate.isBlank()) {
    throw new IllegalArgumentException("coordinate must be group:artifact:version");
}
String[] parts = coordinate.trim().split(":");
if (parts.length < 3 || parts.length > 4) {
    throw new IllegalArgumentException("expected group:artifact:version[:ext]");
}

Type guard

static boolean isValidCoordinate(String c) {
    return c != null && c.trim().matches("[\\w.-]+:[\\w.-]+:[\\w.-]+(:[\\w.-]+)?");
}

Try / catch

try {
    resolver.rootArtifact(coordinate);
} catch (IllegalArgumentException e) {
    log.error("Bad maven coordinate '{}': {}", coordinate, e.getMessage());
}

Prevention

When it happens

Trigger: Calling rootArtifact() with a null or blank coordinate, e.g. running the resolver CLI without a positional coordinate and with no --coordinate/-c flag set.

Common situations: CLI invoked with no arguments; --coordinate flag forgotten; an empty string passed from a script or CI variable that failed to interpolate.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05). Data as JSON: /api/errors/254e97a5ed4a41d2. Report an issue: GitHub.