apache/beam · error
error getting stream
Error message
error getting stream: %v
What it means
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.
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
Example fix
// before stream: "ORDERS_V2" // actual stream is ORDERS // after stream: "ORDERS" // matches `nats stream ls` output
Defensive patterns
Strategy: validation
Validate before calling
// pre-flight before running Estimate
js, _ := jetstream.New(nc)
_, err := js.Stream(ctx, streamName)
if errors.Is(err, jetstream.ErrStreamNotFound) {
return fmt.Errorf("stream %q does not exist on server; check config", streamName)
} Try / catch
str, err := e.js.Stream(ctx, e.stream)
if err != nil {
if errors.Is(err, jetstream.ErrStreamNotFound) {
return -1, fmt.Errorf("stream %q not found: verify configuration", e.stream)
}
if ctx.Err() != nil { /* retry or surface timeout */ }
return -1, fmt.Errorf("error getting stream: %v", err)
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- error creating JetStream context
- error getting last message
- err
- error connecting to NATS
- error creating consumer
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/9fae65dc82bdea51.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/go/pkg/beam/io/natsio/end_estimator.go:52
js: js,
stream: stream,
subject: subject,
}
}
func (e *endEstimator) Estimate() int64 {
ctx := context.Background()
end, err := e.getEndSeqNo(ctx)
if err != nil {
panic(err)
}
return end
}
func (e *endEstimator) getEndSeqNo(ctx context.Context) (int64, error) {
str, err := e.js.Stream(ctx, e.stream)
if err != nil {
return -1, fmt.Errorf("error getting stream: %v", err)
}
msg, err := str.GetLastMsgForSubject(ctx, e.subject)
if err != nil {
if isMessageNotFound(err) {
return 1, nil
}
return -1, fmt.Errorf("error getting last message: %v", err)
}
return int64(msg.Sequence) + 1, nil
}
func isMessageNotFound(err error) bool {
var jsErr jetstream.JetStreamError
if errors.As(err, &jsErr) {
apiErr := jsErr.APIError()View on GitHub (pinned to 12126d8942)