{"record":{"id":"2ecab1d9b8e6ba3d","repo":"apache/beam","slug":"failed-to-retrieve-chunk-for-v","errorCode":null,"errorMessage":"failed to retrieve chunk for %v","messagePattern":"failed to retrieve chunk for (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/artifact/materialize.go","lineNumber":244,"sourceCode":"\tif err := os.MkdirAll(filepath.Dir(filename), os.ModePerm); err != nil {\n\t\treturn err\n\t}\n\n\tstream, err := a.client.GetArtifact(ctx, &jobpb.GetArtifactRequest{Artifact: a.dep})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfd, err := os.OpenFile(filename, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0755)\n\tif err != nil {\n\t\treturn err\n\t}\n\tw := bufio.NewWriter(fd)\n\n\tsha256Hash, err := writeChunks(stream, w)\n\tif err != nil {\n\t\tfd.Close() // drop any buffered content\n\t\treturn errors.Wrapf(err, \"failed to retrieve chunk for %v\", filename)\n\t}\n\tif err := w.Flush(); err != nil {\n\t\tfd.Close()\n\t\treturn errors.Wrapf(err, \"failed to flush chunks for %v\", filename)\n\t}\n\tstat, _ := fd.Stat()\n\tlog.Printf(\"Downloaded: %v (sha256: %v, size: %v)\", filename, sha256Hash, stat.Size())\n\n\tif err := fd.Close(); err != nil {\n\t\treturn err\n\t}\n\n\tif isArtifactValidationEnabled(ctx) {\n\t\tif a.expectedSha256 == \"\" {\n\t\t\tlog.Printf(\"WARN: Artifact validation skipped for file: %v\", filename)\n\t\t} else if sha256Hash != a.expectedSha256 {\n\t\t\treturn errors.Errorf(\"bad SHA256 for %v: %v, want %v\", filename, sha256Hash, a.expectedSha256)\n\t\t}","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/artifact/materialize.go#L226-L262","documentation":"Wraps any error from writeChunks during streaming download in artifact.retrieve: a gRPC stream Recv failed mid-transfer, or a chunk could not be written to the buffered writer. The artifact file is closed and partially downloaded content is abandoned. The filename is included in the message.","triggerScenarios":"Calling Materialize/Retrieve where the GetArtifact server stream errors mid-transfer: artifact staging service restarted, network drop between worker and staging endpoint, gRPC deadline exceeded, or the local disk filled so bufio writes failed.","commonSituations":"Unstable network between worker and artifact server; large artifacts exceeding deadlines; the staging service crashing while serving; disk quota/full volume on the worker node.","solutions":["MultiRetrieve already retries up to 3 times; verify the artifact service is healthy and the network is stable, then rerun the pipeline.","Check free disk space on the worker for dest and enlarge the volume or clean old artifacts.","Increase gRPC/context deadlines if large artifacts are timing out.","Confirm the artifact server endpoint is reachable and not behind a proxy dropping long streams."],"exampleFix":"// before: default ctx without deadline control\nctx := context.Background()\n// after: give retrieval ample time\nctx, cancel := context.WithTimeout(context.Background(), 30*time.Minute)\ndefer cancel()","handlingStrategy":"retry","validationCode":"// Check endpoint reachability and disk headroom before retrieval:\nconn, err := net.DialTimeout(\"tcp\", endpointHost, 5*time.Second)\nif err != nil { return err }\nconn.Close()\nif st, err := os.Stat(dest); err != nil || !st.IsDir() { return fmt.Errorf(\"dest missing: %s\", dest) }","typeGuard":null,"tryCatchPattern":"err := artifact.Materialize(ctx, endpoint, deps, rt, dest)\nfor attempt := 0; err != nil && attempt < 3; attempt++ {\n\tif strings.Contains(err.Error(), \"failed to retrieve chunk\") {\n\t\ttime.Sleep(time.Duration(attempt+1) * 10 * time.Second) // backoff; transient stream drop\n\t\terr = artifact.Materialize(ctx, endpoint, deps, rt, dest)\n\t\tcontinue\n\t}\n\tbreak\n}","preventionTips":["Run workers in a network-stable environment close to the artifact service.","Ensure sufficient free disk space for the largest artifact.","Set generous context deadlines for large artifact downloads.","Monitor artifact service health before job submission."],"tags":["go","grpc","network","streaming","beam-artifacts"],"backgroundTag":"network-request-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}