{"record":{"id":"f3d32280084345ea","repo":"GoogleContainerTools/skaffold","slug":"getting-hash-for-q-w","errorCode":null,"errorMessage":"getting hash for %q: %w","messagePattern":"getting hash for %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/tag/input_digest.go","lineNumber":82,"sourceCode":"\tif image.KanikoArtifact != nil {\n\t\tsrcFiles = append(srcFiles, image.KanikoArtifact.DockerfilePath)\n\t}\n\n\tif image.CustomArtifact != nil && image.CustomArtifact.Dependencies != nil && image.CustomArtifact.Dependencies.Dockerfile != nil {\n\t\tsrcFiles = append(srcFiles, image.CustomArtifact.Dependencies.Dockerfile.Path)\n\t}\n\n\t// must sort as hashing is sensitive to the order in which files are processed\n\tsort.Strings(srcFiles)\n\tfor _, d := range srcFiles {\n\t\th, err := fileHasher(d, image.Workspace)\n\t\tif err != nil {\n\t\t\tif os.IsNotExist(err) {\n\t\t\t\tlog.Entry(ctx).Tracef(\"skipping dependency %q for artifact cache calculation: %v\", d, err)\n\t\t\t\tcontinue // Ignore files that don't exist\n\t\t\t}\n\n\t\t\treturn \"\", fmt.Errorf(\"getting hash for %q: %w\", d, err)\n\t\t}\n\t\tinputs = append(inputs, h)\n\t}\n\n\treturn encode(inputs)\n}\n\nfunc encode(inputs []string) (string, error) {\n\t// get a key for the hashes\n\thasher := sha256.New()\n\tenc := json.NewEncoder(hasher)\n\tif err := enc.Encode(inputs); err != nil {\n\t\treturn \"\", err\n\t}\n\treturn hex.EncodeToString(hasher.Sum(nil)), nil\n}\n\n// fileHasher hashes the contents and name of a file","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/tag/input_digest.go#L64-L100","documentation":"The inputDigest Tagger hashes the artifact's build dependencies to derive a deterministic tag. For each dependency file it opens/hashes the file; if hashing a file fails for a reason other than the file not existing (which is skipped), the error is wrapped as 'getting hash for %q:'.","triggerScenarios":"GenerateTag on an artifact whose dependency paths include a file that exists in the dependency list but cannot be opened/hashed: permission-denied, a path that is a directory, a broken symlink, or an I/O error while reading.","commonSituations":"Dependencies declared in skaffold.yaml pointing to paths with wrong permissions in CI; a dependency listed as a directory or glob that resolves oddly; files deleted between listing and hashing in a concurrently modified workspace.","solutions":["Fix permissions on the dependency file (chmod/chown so the build user can read it)","Remove or correct the offending dependency path in skaffold.yaml build.artifacts.dependencies","Re-run after syncing the workspace — the file may have been deleted concurrently","Point dependencies at regular files, not directories or broken symlinks"],"exampleFix":"// before\ndependencies:\n  - paths: [\"secrets.key\"]   # mode 0600, owned by root\n// after\nsudo chmod a+r secrets.key   # or list a readable copy in dependencies","handlingStrategy":"validation","validationCode":"for _, d := range artifact.Dependencies {\n    if _, err := os.Stat(d); os.IsPermission(err) || isDir(d) {\n        return fmt.Errorf(\"dependency %q unreadable or not a regular file\", d)\n    }\n}","typeGuard":null,"tryCatchPattern":"tag, err := tagger.GenerateTag(ctx, image)\nvar pathErr error\nif errors.As(err, &pathErr) {\n    return fmt.Errorf(\"check permissions/existence of dependency files: %w\", err)\n}","preventionTips":["Verify dependency paths in skaffold.yaml are readable regular files","Avoid listing directories or volatile temp files as dependencies","Run builds with a user that owns/can-read the workspace","Re-check dependencies after concurrent workspace mutations"],"tags":["go","skaffold","hashing","filesystem","tagging"],"backgroundTag":"file-read-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"}