{"record":{"id":"83ed1cec90bd8b2e","repo":"apache/beam","slug":"stepconfig-initialsplits-must-be-1-got-v","errorCode":null,"errorMessage":"StepConfig.InitialSplits must be >= 1. Got: %v","messagePattern":"StepConfig\\.InitialSplits must be >= 1\\. Got: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/io/synthetic/step.go","lineNumber":244,"sourceCode":"// Each resulting restriction will have at least 1 element in it, and each\n// element being emitted will be contained in exactly one restriction. That\n// means that if the desired number of splits is greater than the OutputPerInput\n// N, then N initial restrictions will be created, each containing 1 element.\n//\n// Valid values are in the range of [1, ...] and the default value is 1. Values\n// of 0 (and below) are invalid as they would result in dropping elements that\n// are expected to be emitted.\nfunc (b *StepConfigBuilder) InitialSplits(val int) *StepConfigBuilder {\n\tb.cfg.InitialSplits = val\n\treturn b\n}\n\n// Build constructs the StepConfig initialized by this builder. It also performs\n// error checking on the fields, and panics if any have been set to invalid\n// values.\nfunc (b *StepConfigBuilder) Build() StepConfig {\n\tif b.cfg.InitialSplits <= 0 {\n\t\tpanic(fmt.Sprintf(\"StepConfig.InitialSplits must be >= 1. Got: %v\", b.cfg.InitialSplits))\n\t}\n\tif b.cfg.OutputPerInput < 0 {\n\t\tpanic(fmt.Sprintf(\"StepConfig.OutputPerInput cannot be negative. Got: %v\", b.cfg.OutputPerInput))\n\t}\n\treturn b.cfg\n}\n\n// StepConfig is a struct containing all the configuration options for a\n// synthetic step. It should be created via a StepConfigBuilder, not by directly\n// initializing it (the fields are public to allow encoding).\ntype StepConfig struct {\n\tOutputPerInput int\n\tFilterRatio    float64\n\tSplittable     bool\n\tInitialSplits  int\n}\n","sourceCodeStart":226,"sourceCodeEnd":261,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/io/synthetic/step.go#L226-L261","documentation":"StepConfigBuilder.Build() in the Beam Go synthetic step panics when InitialSplits is less than 1. InitialSplits controls how many initial splits the synthetic step generates, and a zero or negative count is invalid. This fails fast during pipeline construction.","triggerScenarios":"Calling StepConfigBuilder.Build() after StepConfigBuilder.InitialSplits(0) or a negative value, or building from config where InitialSplits defaulted to 0 because it was never set.","commonSituations":"Forgetting to set InitialSplits on a zero-valued builder struct; loading config from JSON/env where the field was omitted; computing the split count from an empty slice length.","solutions":["Set InitialSplits to at least 1 before calling Build().","If the value is computed, guard against len(list) == 0 and fall back to 1.","When deserializing config, apply a default (e.g. 1) when the field is missing or zero."],"exampleFix":"// before\nb := &synthetic.StepConfigBuilder{}\ncfg := b.Build() // InitialSplits is 0\n// after\nb := (&synthetic.StepConfigBuilder{}).InitialSplits(1)\ncfg := b.Build()","handlingStrategy":"validation","validationCode":"if cfg.InitialSplits < 1 {\n    return fmt.Errorf(\"InitialSplits must be >= 1, got %d\", cfg.InitialSplits)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Apply defaults at config load time (missing InitialSplits -> 1).","Never build a StepConfigBuilder without explicitly setting InitialSplits.","Guard computed split counts against empty/zero inputs."],"tags":["go","apache-beam","config-validation","panic"],"backgroundTag":"invalid-config-value","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"}