From eec08cacbed67b068c7be32e4b3ace49c8fb745f Mon Sep 17 00:00:00 2001 From: mitchell Date: Wed, 13 May 2026 15:31:57 -0400 Subject: [PATCH] Remove partially-unpacked directory if the unpack failed. If the directory exists, the depot thinks it's a full artifact, but a failed unpack does not create a runtime.json file, which raises a different error. This masks the original unpacking error. --- pkg/runtime/setup.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/runtime/setup.go b/pkg/runtime/setup.go index f789991acc..c19984d31c 100644 --- a/pkg/runtime/setup.go +++ b/pkg/runtime/setup.go @@ -406,7 +406,11 @@ func (s *setup) unpack(artifact *buildplan.Artifact, b []byte) (rerr error) { return nil }, }, bytes.NewReader(b)) - if err := ua.Unarchive(proxy, s.depot.Path(artifact.ArtifactID)); err != nil { + unpackPath := s.depot.Path(artifact.ArtifactID) + if err := ua.Unarchive(proxy, unpackPath); err != nil { + if err2 := os.RemoveAll(unpackPath); err2 != nil { + return errs.Pack(err, errs.Wrap(err2, "unable to remove partially-unpacked directory")) + } return errs.Wrap(err, "unpack failed") }