spinnaker/spinnaker · error · IllegalStateException

Unable to download artifact with reference

Error message

Unable to download artifact with reference '<reference>'. HTTP <code>

What it means

Thrown by MavenArtifactCredentials.download when the HTTP request to the Maven repository for the artifact file returns a non-success status code (e.g. 401, 403, 404). The reference and HTTP status are included so the caller can tell whether the coordinates, credentials, or repository layout are wrong. It is an IllegalStateException rather than a declared exception because failure to fetch a pinned artifact is considered unrecoverable at this layer.

Solutions

  1. Verify the artifact reference (groupId:artifactId:version) resolves by fetching the same path manually with curl using the same credentials
  2. Check the Maven artifact account's username/password and repositoryUrl in clouddriver config for correctness and read permission
  3. Confirm the artifact still exists in the repository (snapshots may have been purged) and re-pin a valid version
  4. Check proxy/VPN/network settings if the repository is only reachable from certain networks

Example fix

// before
MavenArtifactCredentials creds = new MavenArtifactCredentials(account with wrong password);
InputStream is = creds.download(artifact);
// after
MavenArtifactAccount fixedAccount = account.toBuilder()
    .username("correct-user").password("correct-token").build();
MavenArtifactCredentials creds = new MavenArtifactCredentials(fixedAccount);
// pre-check
assert creds.resolveArtifactName(artifact).isPresent();
Defensive patterns

Strategy: validation

Validate before calling

// Verify the artifact resolves before downloading
if (!creds.resolveArtifactName(artifact).isPresent()) {
  throw new IllegalStateException("Artifact not resolvable in repository: " + artifact.getReference());
}

Try / catch

try {
  stream = creds.download(artifact);
} catch (IllegalStateException e) {
  if (e.getMessage().contains("HTTP 40")) { /* fix reference or credentials, no retry */ }
  else { /* transient, may retry with backoff */ }
}

Prevention

When it happens

Trigger: Calling download(artifact) on a Maven artifact account where repositoryUrl + '/' + artifactPath returns HTTP >= 400: the artifact version does not exist in the repo, the credentials lack read access, or the repository URL is wrong/mis-proxied.

Common situations: Typo in groupId/artifactId/version in a pipeline artifact reference; anonymous access disabled but no username/password configured; corporate Artifactory/Nexus proxying returning 401; artifact deleted by a snapshot-cleanup policy.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


AI-assisted analysis of spinnaker/spinnaker@1d4a5d0f6d (2026-09-10). Data as JSON: /api/errors/b09f8a6b2ae6de48. Report an issue: GitHub.

Appendix: source

Thrown at clouddriver/clouddriver-artifacts/clouddriver-artifacts-maven/src/main/java/com/netflix/spinnaker/clouddriver/artifacts/maven/MavenArtifactCredentials.java:120

                      repositoryLayout.getLocation(withVersion(requestedArtifact, version), false))
              .map(URI::getPath)
              .orElseThrow(
                  () ->
                      new IllegalStateException(
                          "No versions matching constraint '"
                              + artifact.getVersion()
                              + "' for '"
                              + artifact.getReference()
                              + "'"));

      Request artifactRequest =
          new Request.Builder().url(account.getRepositoryUrl() + "/" + artifactPath).get().build();

      Response artifactResponse = okHttpClient.newCall(artifactRequest).execute();
      if (artifactResponse.isSuccessful()) {
        return artifactResponse.body().byteStream();
      }
      throw new IllegalStateException(
          "Unable to download artifact with reference '"
              + artifact.getReference()
              + "'. HTTP "
              + artifactResponse.code());
    } catch (IOException | ArtifactDownloadException e) {
      throw new IllegalStateException(
          "Unable to download artifact with reference '" + artifact.getReference() + "'", e);
    }
  }

  public Optional<String> resolveArtifactName(Artifact artifact) {
    try {
      final DefaultArtifact aetherArtifact = new DefaultArtifact(artifact.getReference());
      return Optional.of(aetherArtifact.getGroupId() + ":" + aetherArtifact.getArtifactId());
    } catch (Exception e) {
      return Optional.empty();
    }
  }

View on GitHub (pinned to 1d4a5d0f6d)