GoogleContainerTools/skaffold · error

expanding src: %w

Error message

expanding src: %w

What it means

Fires in readCopyCommand when shell expansion of a COPY/ADD source path fails (slex.ProcessWord), e.g. malformed variable substitution or unmatched quoting/escapes in the src argument. Dockerfile parsing succeeded; only path expansion for dependency analysis failed.

Source

Thrown at pkg/skaffold/docker/parse.go:338

			return true
		}
	}
	return false
}

func readCopyCommand(value *parser.Node, envs []string, workdir string) (*copyCommand, error) {
	// If the --from flag is provided, we are dealing with a multi-stage dockerfile
	// Adding a dependency from a different stage does not imply a source dependency
	if hasMultiStageFlag(value.Flags) {
		return nil, nil
	}

	var paths []string
	slex := shell.NewLex('\\')
	for value := value.Next; value != nil && !strings.HasPrefix(value.Value, "#"); value = value.Next {
		path, _, err := slex.ProcessWord(value.Value, shell.EnvsFromSlice(envs))
		if err != nil {
			return nil, fmt.Errorf("expanding src: %w", err)
		}

		paths = append(paths, path)
	}
	if len(paths) == 0 {
		return nil, fmt.Errorf("invalid dockerfile instruction: %q", value.Original)
	}

	// All paths are sources except the last one
	var srcs []string
	for _, src := range paths[0 : len(paths)-1] {
		if hasOneOfPrefixes(src, []string{"http://", "https://", "<<"}) {
			log.Entry(context.TODO()).Debugln("Skipping watch on remote/heredoc dependency", src)
			continue
		}

		srcs = append(srcs, src)
	}

View on GitHub (pinned to a1189de023)

Solutions

  1. Simplify the COPY/ADD source path (avoid complex variable expansion)
  2. Declare the required ARG/ENV variables used in the path
  3. Fix unbalanced quotes or escapes in the COPY instruction
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at pkg/skaffold/docker/parse.go:338 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05). Data as JSON: /api/errors/dd5ad3b35e8d7de2. Report an issue: GitHub.