{"record":{"id":"9fae65dc82bdea51","repo":"apache/beam","slug":"error-getting-stream-v","errorCode":null,"errorMessage":"error getting stream: %v","messagePattern":"error getting stream: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/io/natsio/end_estimator.go","lineNumber":52,"sourceCode":"\t\tjs:      js,\n\t\tstream:  stream,\n\t\tsubject: subject,\n\t}\n}\n\nfunc (e *endEstimator) Estimate() int64 {\n\tctx := context.Background()\n\tend, err := e.getEndSeqNo(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn end\n}\n\nfunc (e *endEstimator) getEndSeqNo(ctx context.Context) (int64, error) {\n\tstr, err := e.js.Stream(ctx, e.stream)\n\tif err != nil {\n\t\treturn -1, fmt.Errorf(\"error getting stream: %v\", err)\n\t}\n\n\tmsg, err := str.GetLastMsgForSubject(ctx, e.subject)\n\tif err != nil {\n\t\tif isMessageNotFound(err) {\n\t\t\treturn 1, nil\n\t\t}\n\n\t\treturn -1, fmt.Errorf(\"error getting last message: %v\", err)\n\t}\n\n\treturn int64(msg.Sequence) + 1, nil\n}\n\nfunc isMessageNotFound(err error) bool {\n\tvar jsErr jetstream.JetStreamError\n\tif errors.As(err, &jsErr) {\n\t\tapiErr := jsErr.APIError()","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/io/natsio/end_estimator.go#L34-L70","documentation":"endEstimator.getEndSeqNo looks up the JetStream stream by name via e.js.Stream(ctx, e.stream) to determine the last sequence number for estimation. If the stream cannot be retrieved, the error is wrapped with this message and Estimate fails. Typically the configured stream name does not exist on the server.","triggerScenarios":"js.Stream(ctx, e.stream) returns nats.ErrStreamNotFound or a context/transport error: the stream name in the estimator config doesn't match any existing stream, the request times out, or the JetStream context is invalid.","commonSituations":"Typo in the stream name in pipeline options; stream deleted or renamed before the job runs; connecting to the wrong NATS environment/account where the stream doesn't exist; network blip during the lookup.","solutions":["Verify the stream name matches an existing stream (`nats stream ls` / `nats stream info <name>`)","Check the pipeline's stream configuration/flag for typos and correct environment/account","Recreate the stream if it was deleted before running the job","Inspect the wrapped error for context deadline issues and increase the timeout or retry"],"exampleFix":"// before\nstream: \"ORDERS_V2\" // actual stream is ORDERS\n// after\nstream: \"ORDERS\" // matches `nats stream ls` output","handlingStrategy":"validation","validationCode":"// pre-flight before running Estimate\njs, _ := jetstream.New(nc)\n_, err := js.Stream(ctx, streamName)\nif errors.Is(err, jetstream.ErrStreamNotFound) {\n\treturn fmt.Errorf(\"stream %q does not exist on server; check config\", streamName)\n}","typeGuard":null,"tryCatchPattern":"str, err := e.js.Stream(ctx, e.stream)\nif err != nil {\n\tif errors.Is(err, jetstream.ErrStreamNotFound) {\n\t\treturn -1, fmt.Errorf(\"stream %q not found: verify configuration\", e.stream)\n\t}\n\tif ctx.Err() != nil { /* retry or surface timeout */ }\n\treturn -1, fmt.Errorf(\"error getting stream: %v\", err)\n}","preventionTips":["Confirm stream names with `nats stream ls` before configuring the estimator","Use the same account/environment for config generation and job execution","Guard against stream deletion with retention policies/permissions","Set generous context timeouts for stream metadata lookups"],"tags":["nats","jetstream","stream","not-found","beam-io"],"backgroundTag":"entity-not-found","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"}