Skip to content

Commit

Permalink
fix(bake): Improve error message (#375)
Browse files Browse the repository at this point in the history
When supplying an artifact without a reference, we currently
throw an NPE that is hard to debug. Replace this with a better
error message.

(At some point we could consider if we even need a reference at
all, or if we could fall back to something else, but for now this
will at least make the restriction clearer.)
  • Loading branch information
ezimanyi committed May 20, 2019
1 parent a8d60cb commit a86c365
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.amazonaws.util.IOUtils;
import com.netflix.spinnaker.kork.artifacts.model.Artifact;
import com.netflix.spinnaker.kork.core.RetrySupport;
import com.netflix.spinnaker.kork.web.exceptions.InvalidRequestException;
import com.netflix.spinnaker.rosco.jobs.BakeRecipe;
import com.netflix.spinnaker.rosco.services.ClouddriverService;
import lombok.Getter;
Expand Down Expand Up @@ -41,6 +42,9 @@ private String nameFromReference(String reference) {
}

protected Path downloadArtifactToTmpFile(BakeManifestEnvironment env, Artifact artifact) throws IOException {
if (artifact.getReference() == null) {
throw new InvalidRequestException("Input artifact has an empty 'reference' field.");
}
Path path = Paths.get(env.getStagingPath().toString(), nameFromReference(artifact.getReference()));
OutputStream outputStream = new FileOutputStream(path.toString());

Expand Down

0 comments on commit a86c365

Please sign in to comment.