{"record":{"id":"6f5e96c6fcd75fb3","repo":"argoproj/argo-workflows","slug":"failed-to-copy-s-to-s-w","errorCode":null,"errorMessage":"failed to copy %s to %s: %w","messagePattern":"failed to copy (.+?) to (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/argoexec/commands/emissary.go","lineNumber":756,"sourceCode":"\t\treturn fmt.Errorf(\"failed to open %s: %w\", srcPath, err)\n\t}\n\tdefer func() { _ = src.Close() }()\n\tdstPath := varRunArgo + \"/outputs/parameters/\" + srcPath\n\tlogger.WithFields(logging.Fields{\n\t\t\"src\": srcPath,\n\t\t\"dst\": dstPath,\n\t}).Info(ctx, \"saving parameter\")\n\tz := filepath.Dir(dstPath)\n\tif mkdirErr := os.MkdirAll(z, 0o755); mkdirErr != nil { // chmod rwxr-xr-x\n\t\treturn fmt.Errorf(\"failed to create directory %s: %w\", z, mkdirErr)\n\t}\n\tdst, err := os.Create(dstPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create %s: %w\", srcPath, err)\n\t}\n\tdefer func() { _ = dst.Close() }()\n\tif _, err = io.Copy(dst, src); err != nil {\n\t\treturn fmt.Errorf(\"failed to copy %s to %s: %w\", srcPath, dstPath, err)\n\t}\n\tif err = dst.Close(); err != nil {\n\t\treturn fmt.Errorf(\"failed to close %s: %w\", dstPath, err)\n\t}\n\treturn nil\n}\n","sourceCodeStart":738,"sourceCodeEnd":763,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/cmd/argoexec/commands/emissary.go#L738-L763","documentation":"saveParameter failed while copying the parameter source file's contents to the destination file with io.Copy. The parameter file was opened and created, but the transfer failed mid-way — typically a read error on src or a write/ENOSPC error on dst. The destination file may be partially written and the parameter will be missing or corrupt.","triggerScenarios":"io.Copy(dst, src) returns error: the source file shrank/was deleted mid-read, src is a special file that errors on read, dst hits ENOSPC during write, or underlying storage I/O error.","commonSituations":"Script truncates/rotates the output file while the executor reads it; disk fills while writing large parameter values (parameters should be small); failing node storage.","solutions":["Ensure the script finishes writing the parameter file before the main process exits (write atomically: write temp file then rename).","Keep parameter values small — use artifacts for large outputs; free disk space if ENOSPC.","Retry the step; persistent errors point to node storage problems — investigate/move workloads.","Verify no other process in the pod deletes or truncates the parameter path during execution."],"exampleFix":"// before: in-place writes can be observed mid-write\nprintf 'partial'; printf ' value' >> /tmp/out\n// after: atomic write so the reader never sees a partial file\nprintf value > /tmp/out.tmp && mv /tmp/out.tmp /tmp/out","handlingStrategy":"try-catch","validationCode":"// in the step script: write parameters atomically and keep them small\n// size check before declaring a parameter from a file\nif fi, err := os.Stat(paramPath); err == nil && fi.Size() > 256*1024 {\n    return errors.New(\"parameter too large; use an artifact instead\")\n}","typeGuard":null,"tryCatchPattern":"err := runStep(ctx)\nif err != nil && strings.Contains(err.Error(), \"failed to copy\") {\n    // src mutated or ENOSPC mid-copy: retry the step; make scripts write atomically\n    return retryWithBackoff(ctx, err)\n}","preventionTips":["Write parameter files atomically (temp file + rename) in step scripts","Don't truncate or rotate the parameter file while the step runs","Use artifacts, not parameters, for large outputs","Add retryStrategy on steps so transient I/O failures self-heal"],"tags":["argo-workflows","argoexec","parameters","filesystem","io"],"backgroundTag":"file-copy-failed","analyzedSha":"35bff19146f5a6ada77468c431f2624bd577e373","analyzedAt":"2026-09-03T19:34:35.908Z","contentChangedAt":"2026-09-03T19:34:35.908Z","schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}