apache/beam · error
StepConfig.OutputPerInput cannot be negative. Got
Error message
StepConfig.OutputPerInput cannot be negative. Got: %v
What it means
StepConfigBuilder.Build() panics when OutputPerInput is negative. This field controls how many output records each input produces in the synthetic step; only non-negative counts are valid. It is a fail-fast validation during pipeline graph construction.
Solutions
- Set OutputPerInput to 0 or a positive value before Build().
- Clamp computed values: if n < 0 { n = 0 }.
- Replace -1 sentinels with explicit 0 or use an optional pointer field in your config layer.
Example fix
// before b.OutputPerInput(-1) // meant 'no extra outputs' // after b.OutputPerInput(0)
Defensive patterns
Strategy: validation
Validate before calling
if cfg.OutputPerInput < 0 {
return fmt.Errorf("OutputPerInput must be >= 0, got %d", cfg.OutputPerInput)
} Prevention
- Clamp computed values to zero as a lower bound.
- Avoid -1 as an 'unset' sentinel in configs.
- Add table-driven tests covering boundary values of StepConfig.
When it happens
Trigger: Calling StepConfigBuilder.Build() after OutputPerInput(-1) or any negative value, typically from a bad computed value or a negative number in a JSON/env-driven config.
Common situations: Subtracting to compute a delta that goes negative; misconfigured synthetic load-testing pipelines; copying a config template and hand-editing a value to -1 meaning 'unset'.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- SourceConfig.HotKeyFraction must be a floating point number…
- StepConfig.InitialSplits must be >= 1. Got
- AfterProcessingTime trigger set without a delay or…
- At least one subtrigger required for composite triggers.
- attempted to add namespace to missing coder id
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/8e3c05800166b3a2.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/go/pkg/beam/io/synthetic/step.go:247
// N, then N initial restrictions will be created, each containing 1 element.
//
// Valid values are in the range of [1, ...] and the default value is 1. Values
// of 0 (and below) are invalid as they would result in dropping elements that
// are expected to be emitted.
func (b *StepConfigBuilder) InitialSplits(val int) *StepConfigBuilder {
b.cfg.InitialSplits = val
return b
}
// Build constructs the StepConfig initialized by this builder. It also performs
// error checking on the fields, and panics if any have been set to invalid
// values.
func (b *StepConfigBuilder) Build() StepConfig {
if b.cfg.InitialSplits <= 0 {
panic(fmt.Sprintf("StepConfig.InitialSplits must be >= 1. Got: %v", b.cfg.InitialSplits))
}
if b.cfg.OutputPerInput < 0 {
panic(fmt.Sprintf("StepConfig.OutputPerInput cannot be negative. Got: %v", b.cfg.OutputPerInput))
}
return b.cfg
}
// StepConfig is a struct containing all the configuration options for a
// synthetic step. It should be created via a StepConfigBuilder, not by directly
// initializing it (the fields are public to allow encoding).
type StepConfig struct {
OutputPerInput int
FilterRatio float64
Splittable bool
InitialSplits int
}
View on GitHub (pinned to 12126d8942)