{"record":{"id":"cad733b3963a130f","repo":"apache/beam","slug":"failed-to-stage-artifact-v","errorCode":null,"errorMessage":"failed to stage artifact %v","messagePattern":"failed to stage artifact (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/artifact/gcsproxy/staging.go","lineNumber":145,"sourceCode":"\t}\n\tmd := header.GetMetadata().GetMetadata()\n\tif md == nil {\n\t\treturn errors.Errorf(\"expected header as first message: %v\", header)\n\t}\n\tobject := path.Join(s.root, md.Name)\n\n\t// Stream content to GCS. We don't have to worry about partial\n\t// or abandoned writes, because object writes are atomic.\n\n\tctx := ps.Context()\n\tcl, err := gcsx.NewClient(ctx, storage.ScopeReadWrite)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to create GCS client\")\n\t}\n\n\tr := &reader{sha256W: sha256.New(), stream: ps}\n\tif err := gcsx.WriteObject(ctx, cl, s.bucket, object, r); err != nil {\n\t\treturn errors.Wrapf(err, \"failed to stage artifact %v\", md.Name)\n\t}\n\thash := r.SHA256()\n\tif md.Sha256 != \"\" && md.Sha256 != hash {\n\t\treturn errors.Errorf(\"invalid SHA256 for artifact %v: %v want %v\", md.Name, hash, md.Sha256)\n\t}\n\n\ts.mu.Lock()\n\ts.blobs[md.Name] = staged{object: gcsx.MakeObject(s.bucket, object), hash: hash}\n\ts.mu.Unlock()\n\n\treturn ps.SendAndClose(&jobpb.PutArtifactResponse{})\n}\n\n// reader is an adapter between the artifact stream and the GCS stream reader.\n// It also computes the SHA256 of the content.\ntype reader struct {\n\tsha256W hash.Hash\n\tbuf     []byte","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/artifact/gcsproxy/staging.go#L127-L163","documentation":"Error returned by PutArtifact in the GCS artifact staging proxy when gcsx.WriteObject fails while streaming artifact content to the bucket under s.root. The underlying GCS client/write error is wrapped; because object writes are atomic, a failed write leaves no partial object, but the artifact was not staged and staging must be retried or diagnosed.","triggerScenarios":"GCS write fails: bucket doesn't exist or lacks write permission; reader (client stream) errors mid-upload; context cancelled during transfer.","commonSituations":"Wrong bucket configured on StagingServer; client disconnects mid-upload causing reader error; GCS rate limits or quota exhaustion during large uploads.","solutions":["Check the wrapped error for the underlying cause (permissions, bucket name, stream EOF)","Verify s.bucket is correct and writable by the service account","Retry the PutArtifact call; ensure the client keeps the stream open for the whole upload"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// pre-check bucket writability\nit := client.Bucket(bucket).Objects(ctx, nil)\n_, err := it.Next() // confirms bucket exists/access","typeGuard":null,"tryCatchPattern":"if err := stream.PutArtifact(ctx); err != nil && strings.Contains(err.Error(), \"failed to stage artifact\") {\n    // inspect wrapped cause; fix bucket/permissions or retry upload\n}","preventionTips":["Validate bucket name and permissions at server startup","Keep client streams open for the entire artifact upload","Handle GCS quota/rate limits with backoff"],"tags":["gcs","write","streaming","artifact-staging"],"backgroundTag":"file-write-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}