{"record":{"id":"180816d2ebb93733","repo":"GoogleContainerTools/skaffold","slug":"cannot-write-to-temp-file-w","errorCode":null,"errorMessage":"cannot write to temp file: %w","messagePattern":"cannot write to temp file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/helm/util.go","lineNumber":45,"sourceCode":")\n\n// copy of cmd/skaffold/app/flags.BuildOutputs\ntype buildOutputs struct {\n\tBuilds []graph.Artifact `json:\"builds\"`\n}\n\nfunc writeBuildArtifacts(builds []graph.Artifact) (string, func(), error) {\n\tbuildOutput, err := json.Marshal(buildOutputs{builds})\n\tif err != nil {\n\t\treturn \"\", nil, fmt.Errorf(\"cannot marshal build artifacts: %w\", err)\n\t}\n\n\tf, err := os.CreateTemp(\"\", \"builds*.yaml\")\n\tif err != nil {\n\t\treturn \"\", nil, fmt.Errorf(\"cannot create temp file: %w\", err)\n\t}\n\tif _, err := f.Write(buildOutput); err != nil {\n\t\treturn \"\", nil, fmt.Errorf(\"cannot write to temp file: %w\", err)\n\t}\n\tif err := f.Close(); err != nil {\n\t\treturn \"\", nil, fmt.Errorf(\"cannot close temp file: %w\", err)\n\t}\n\treturn f.Name(), func() { os.Remove(f.Name()) }, nil\n}\n\n// SanitizeFilePath is used to sanitize filepaths that are provided to the `setFiles` flag\n// helm `setFiles` doesn't work with the unescaped filepath separator (\\) for Windows or if there are unescaped tabs and spaces in the directory names.\n// So we escape all odd count occurrences of `\\` for Windows, and wrap the entire string in quotes if it has spaces.\n// This is very specific to the way helm handles its flags.\n// See https://github.com/helm/helm/blob/d55c53df4e394fb62b0514a09c57bce235dd7877/pkg/cli/values/options.\n// Otherwise the windows `syscall` package implements its own sanitizing for command args that's used by `exec.Cmd`.\n// See https://github.com/golang/go/blob/6951da56b0ae2cd4250fc1b0350d090aed633ac1/src/syscall/exec_windows.go#L27\nfunc SanitizeFilePath(s string, isWindowsOS bool) string {\n\tif len(s) == 0 {\n\t\treturn `\"\"`\n\t}","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/helm/util.go#L27-L63","documentation":"writeBuildArtifacts writes the marshaled JSON to the temp file. If f.Write fails after successful creation, this error is returned, aborting post-renderer setup. It indicates an I/O problem on an already-open temp file handle.","triggerScenarios":"f.Write(buildOutput) returns an error mid-write: disk became full, the underlying device returned EIO, or (in rare fd-exhaustion/edge cases) the write is interrupted with no short-write handling.","commonSituations":"tmpfs filling up between create and write; failing disk or network storage backing TMPDIR; storage quota exceeded in CI.","solutions":["Check free space on the temp filesystem and clean up (`df -h; rm -rf /tmp/builds*`)","Retry the operation after freeing disk/quota","Point TMPDIR at a different, healthy filesystem","If persistent, check dmesg/storage health for I/O errors"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"TD=\"${TMPDIR:-/tmp}\"; [ \"$(stat -f -c %a \"$TD\" 2>/dev/null || df --output=avail \"$TD\" | tail -1)\" -gt 104857600 ] || { echo \"insufficient space on temp filesystem\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep generous free space on the filesystem backing TMPDIR","Monitor disk I/O errors (dmesg) on CI runners","Avoid network-mounted temp directories","Clean tmpfs usage before deploy steps"],"tags":["temp-file","io","disk-full","helm"],"backgroundTag":"temp-file-write-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"}