{"record":{"id":"67e2e889f53353fd","repo":"argoproj/argo-workflows","slug":"unable-to-open-file-s-w","errorCode":null,"errorMessage":"unable to open file %s: %w","messagePattern":"unable to open file (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"workflow/artifacts/azure/azure.go","lineNumber":333,"sourceCode":"\tcontainerClient, err := azblobDriver.newAzureContainerClient(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to create Azure Blob Container client for %s: %w\", outputArtifact.Azure.Blob, err)\n\t}\n\n\tblobClient := containerClient.NewBlockBlobClient(outputArtifact.Azure.Blob)\n\tif _, err = blobClient.UploadStream(ctx, reader, nil); err != nil {\n\t\treturn fmt.Errorf(\"unable to upload stream to Azure blob %s: %w\", outputArtifact.Azure.Blob, err)\n\t}\n\treturn nil\n}\n\n// PutFile uploads a file to Azure Blob Storage\nfunc PutFile(ctx context.Context, containerClient *container.Client, blobName, path string) error {\n\tblobClient := containerClient.NewBlockBlobClient(blobName)\n\n\tfile, err := os.Open(path)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to open file %s: %w\", path, err)\n\t}\n\tdefer func() {\n\t\tif closeErr := file.Close(); closeErr != nil {\n\t\t\tlogger := logging.RequireLoggerFromContext(ctx)\n\t\t\tlogger.WithError(closeErr).Warn(ctx, \"unable to close file\")\n\t\t}\n\t}()\n\n\t_, err = blobClient.UploadFile(ctx, file, nil)\n\treturn err\n}\n\n// PutDirectory uploads all files in a directory to Azure Blob Storage\nfunc PutDirectory(ctx context.Context, containerClient *container.Client, blobName, path string) error {\n\tfor putTask := range generatePutTasks(blobName, path) {\n\t\terr := PutFile(ctx, containerClient, putTask.blobName, putTask.path)\n\t\tif err != nil {\n\t\t\treturn err","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/workflow/artifacts/azure/azure.go#L315-L351","documentation":"PutFile opens the local file at `path` with os.Open before uploading to Azure. If the file cannot be opened (does not exist, permission denied, path is a broken symlink), the OS error is wrapped with this message. This is a local-filesystem failure, not an Azure failure.","triggerScenarios":"PutFile called by Save/PutDirectory with a path that vanished or is unreadable: file removed during the workflow, wrong path passed, permission restrictions for the executor process.","commonSituations":"Race where a cleanup step deletes files before save; running as non-root while file is 0600 root-owned; symlink to a missing target; directory artifact where a child path was removed mid-walk.","solutions":["Confirm the file exists at the exact path (ls -l) inside the workflow container.","Fix file permissions/ownership so the executor user can read it.","Ensure no concurrent step deletes or moves the file before artifact save.","Check for broken symlinks in directory artifacts.","Use absolute paths and keep artifact paths inside the mounted volume."],"exampleFix":"// before\npath: /work/out.txt   // file deleted by a cleanup step\n// after: keep until after save\nmain: generate → save artifact → cleanup container","handlingStrategy":"validation","validationCode":"f, err := os.Open(path)\nif err != nil { return err }\nf.Close()\n// safe to call PutFile now","typeGuard":"func readableFile(p string) bool {\n  f, err := os.Open(p)\n  if err != nil { return false }\n  f.Close()\n  return true\n}","tryCatchPattern":"err := PutFile(ctx, containerClient, blobName, path)\nif err != nil {\n  var pe *fs.PathError\n  if errors.As(err, &pe) && errors.Is(pe.Err, os.ErrNotExist) {\n    // local file vanished — check producing step and cleanup ordering\n  }\n  return err\n}","preventionTips":["Verify file existence/permissions before artifact save in the template.","Order cleanup steps after artifact save in the pod lifecycle.","Avoid broken symlinks in directory artifacts.","Run workflow containers with a user that can read all output files."],"tags":["filesystem","permissions","artifact","upload"],"backgroundTag":"file-not-found","analyzedSha":"35bff19146f5a6ada77468c431f2624bd577e373","analyzedAt":"2026-09-03T19:34:35.908Z","contentChangedAt":"2026-09-03T19:34:35.908Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}