{"record":{"id":"b7a5b475dc4a58de","repo":"GoogleContainerTools/skaffold","slug":"removing-unused-default-args-w","errorCode":null,"errorMessage":"removing unused default args: %w","messagePattern":"removing unused default args: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/docker/build_args.go","lineNumber":79,"sourceCode":"\tfor k, v := range defaults {\n\t\tresult[k] = &v\n\t}\n\n\tfor k, v := range extra {\n\t\tresult[k] = v\n\t}\n\tabsDockerfilePath, err := NormalizeDockerfilePath(workspace, dockerfilePath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"normalizing dockerfile path: %w\", err)\n\t}\n\tf, err := os.Open(absDockerfilePath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"reading dockerfile: %w\", err)\n\t}\n\tdefer f.Close()\n\tresult, err = filterUnusedBuildArgs(f, result)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"removing unused default args: %w\", err)\n\t}\n\tfor k, v := range args {\n\t\tresult[k] = v\n\t}\n\tresult, err = util.EvaluateEnvTemplateMapWithEnv(result, env)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to expand build args: %w\", err)\n\t}\n\treturn result, nil\n}\n\n// ArtifactResolver provides an interface to resolve built artifact tags by image name.\ntype ArtifactResolver interface {\n\tGetImageTag(imageName string) (string, bool)\n}\n\n// ResolveDependencyImages creates a map of artifact aliases to their built image from a required artifacts slice.\n// If `missingIsFatal` is false then it is permissive of missing entries in the ArtifactResolver and returns nil for those entries.","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/docker/build_args.go#L61-L97","documentation":"Wraps a failure from filterUnusedBuildArgs, which scans the Dockerfile to drop default build args that are not actually used. Failure here means the Dockerfile content could not be scanned/parsed by the filter.","triggerScenarios":"evalBuildArgs calls filterUnusedBuildArgs(f, result) after opening the Dockerfile; the scanner errors, e.g. on a read error or Dockerfile syntax it cannot parse (malformed ARG/ONBUILD lines).","commonSituations":"Dockerfile with unusual constructs or encoding issues; I/O error reading a partially-written file; unexpected parser version behavior.","solutions":["Read the wrapped inner error to find the parse failure point","Fix Dockerfile syntax around ARG declarations","Re-encode the Dockerfile as UTF-8 without BOM","Retry if the file was mid-write (I/O race)"],"exampleFix":"// before\nARG MYARG\nMYARG broken line\n// after\nARG MYARG\nRUN echo $MYARG","handlingStrategy":"try-catch","validationCode":"// sanity-check ARG lines parse as UTF-8 text with valid syntax\nb, err := os.ReadFile(absDockerfilePath)\nif err != nil { return err }\nif !utf8.Valid(b) { return fmt.Errorf(\"dockerfile is not valid UTF-8\") }","typeGuard":null,"tryCatchPattern":"args, err := evalBuildArgs(workspace, df, args, env)\nif err != nil && strings.Contains(err.Error(), \"removing unused default args\") {\n  return fmt.Errorf(\"Dockerfile could not be scanned; check syntax near ARG lines: %w\", err)\n}","preventionTips":["Keep Dockerfile syntax standard (valid ARG/RUN lines)","Save Dockerfiles as UTF-8 without BOM","Run hadolint or `docker build` lint locally first","Retry once on transient I/O errors"],"tags":["docker","build-args","dockerfile","parsing"],"backgroundTag":"dockerfile-parse-failed","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}