{"record":{"id":"8e3c05800166b3a2","repo":"apache/beam","slug":"stepconfig-outputperinput-cannot-be-negative-got-v","errorCode":null,"errorMessage":"StepConfig.OutputPerInput cannot be negative. Got: %v","messagePattern":"StepConfig\\.OutputPerInput cannot be negative\\. Got: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/io/synthetic/step.go","lineNumber":247,"sourceCode":"// 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":229,"sourceCodeEnd":261,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/io/synthetic/step.go#L229-L261","documentation":"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.","triggerScenarios":"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.","commonSituations":"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'.","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."],"exampleFix":"// before\nb.OutputPerInput(-1) // meant 'no extra outputs'\n// after\nb.OutputPerInput(0)","handlingStrategy":"validation","validationCode":"if cfg.OutputPerInput < 0 {\n    return fmt.Errorf(\"OutputPerInput must be >= 0, got %d\", cfg.OutputPerInput)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"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"}