Skip to content

Commit

Permalink
feat: clarify missing file error message
Browse files Browse the repository at this point in the history
The error returned from buildkit was confusing.
This simplifies the error message to the useful
details.

Signed-off-by: Chris Goller <[email protected]>
  • Loading branch information
goller committed Nov 14, 2023
1 parent 2ef3252 commit 2972eb9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/buildx/commands/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"io"
"os"
"path/filepath"
"regexp"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -1093,6 +1094,13 @@ func rewriteFriendlyErrors(err error) error {
if strings.Contains(err.Error(), "header key \"exclude-patterns\" contains value with non-printable ASCII characters") {
return errors.New(err.Error() + ". Please check your .dockerignore file for invalid characters.")
}
if strings.Contains(err.Error(), "failed to calculate checksum of ref") {
pattern := `failed to solve: failed to compute cache key: failed to calculate checksum of ref [^:]+::[^:]+:`
re := regexp.MustCompile(pattern)

simplified := re.ReplaceAllString(err.Error(), "")
return errors.New(simplified + ". Please check if the files exist in the context.")
}
return err
}

Expand Down

0 comments on commit 2972eb9

Please sign in to comment.