apache/beam · error
SourceConfig.ValueSize must be >= 1. Got
Error message
SourceConfig.ValueSize must be >= 1. Got: %v
What it means
Panic raised by synthetic SourceConfigBuilder.Build when cfg.ValueSize is zero or negative. Like the sibling checks on InitialSplits, NumElements and KeySize, this is an eager configuration validation: value byte length must be a positive number or Build refuses to emit a SourceConfig.
Solutions
- Call builder.ValueSize(n) with n >= 1 before Build().
- Clamp the value-size config value to a minimum of 1.
- Validate size fields together in one config-validation pass.
Example fix
// before cfg := synthetic.NewSourceConfig().NumElements(100).KeySize(8).ValueSize(0).Build() // after cfg := synthetic.NewSourceConfig().NumElements(100).KeySize(8).ValueSize(64).Build()
Defensive patterns
Strategy: validation
Validate before calling
if valueSize < 1 {
return fmt.Errorf("synthetic ValueSize must be >= 1, got %d", valueSize)
} Try / catch
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("invalid synthetic source config: %v", r)
}
}() Prevention
- Set ValueSize explicitly in every builder chain.
- Validate key and value sizes together in one check.
- Guard computed payload sizes against empty/zero inputs.
When it happens
Trigger: Building a SourceConfig without ValueSize(n) or with ValueSize(0) / a negative value.
Common situations: Throughput benchmarks where value size is derived from payload config that can be empty, or omitted builder calls.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- SourceConfig.InitialSplits must be >= 1. Got
- SourceConfig.KeySize must be >= 1. Got
- SourceConfig.NumElements must be >= 1. Got
- SourceConfig.NumHotKeys must be >= 0. Got
- capacity of cache cannot be negative, got
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/c7466fb85737f165.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/go/pkg/beam/io/synthetic/source.go:266
b.cfg.HotKeyFraction = val
return b
}
// Build constructs the SourceConfig initialized by this builder. It also
// performs error checking on the fields, and panics if any have been set to
// invalid values.
func (b *SourceConfigBuilder) Build() SourceConfig {
if b.cfg.InitialSplits <= 0 {
panic(fmt.Sprintf("SourceConfig.InitialSplits must be >= 1. Got: %v", b.cfg.InitialSplits))
}
if b.cfg.NumElements <= 0 {
panic(fmt.Sprintf("SourceConfig.NumElements must be >= 1. Got: %v", b.cfg.NumElements))
}
if b.cfg.KeySize <= 0 {
panic(fmt.Sprintf("SourceConfig.KeySize must be >= 1. Got: %v", b.cfg.KeySize))
}
if b.cfg.ValueSize <= 0 {
panic(fmt.Sprintf("SourceConfig.ValueSize must be >= 1. Got: %v", b.cfg.ValueSize))
}
if b.cfg.NumHotKeys < 0 {
panic(fmt.Sprintf("SourceConfig.NumHotKeys must be >= 0. Got: %v", b.cfg.HotKeyFraction))
}
if b.cfg.HotKeyFraction < 0 || b.cfg.HotKeyFraction > 1 {
panic(fmt.Sprintf("SourceConfig.HotKeyFraction must be a floating point number from 0 and 1. Got: %v", b.cfg.NumHotKeys))
}
return b.cfg
}
// BuildFromJSON constructs the SourceConfig by populating it with the parsed
// JSON. Panics if there is an error in the syntax of the JSON or if the input
// contains unknown object keys.
//
// An example of valid JSON object:
//
// {
// "num_records": 5,View on GitHub (pinned to 12126d8942)