{"record":{"id":"d0c328bbb56ebba6","repo":"apache/beam","slug":"sourceconfig-keysize-must-be-1-got-v","errorCode":null,"errorMessage":"SourceConfig.KeySize must be >= 1. Got: %v","messagePattern":"SourceConfig\\.KeySize must be >= 1\\. Got: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/io/synthetic/source.go","lineNumber":263,"sourceCode":"//\n// Valid values are floating point numbers from 0 to 1.\nfunc (b *SourceConfigBuilder) HotKeyFraction(val float64) *SourceConfigBuilder {\n\tb.cfg.HotKeyFraction = val\n\treturn b\n}\n\n// Build constructs the SourceConfig initialized by this builder. It also\n// performs error checking on the fields, and panics if any have been set to\n// invalid values.\nfunc (b *SourceConfigBuilder) Build() SourceConfig {\n\tif b.cfg.InitialSplits <= 0 {\n\t\tpanic(fmt.Sprintf(\"SourceConfig.InitialSplits must be >= 1. Got: %v\", b.cfg.InitialSplits))\n\t}\n\tif b.cfg.NumElements <= 0 {\n\t\tpanic(fmt.Sprintf(\"SourceConfig.NumElements must be >= 1. Got: %v\", b.cfg.NumElements))\n\t}\n\tif b.cfg.KeySize <= 0 {\n\t\tpanic(fmt.Sprintf(\"SourceConfig.KeySize must be >= 1. Got: %v\", b.cfg.KeySize))\n\t}\n\tif b.cfg.ValueSize <= 0 {\n\t\tpanic(fmt.Sprintf(\"SourceConfig.ValueSize must be >= 1. Got: %v\", b.cfg.ValueSize))\n\t}\n\tif b.cfg.NumHotKeys < 0 {\n\t\tpanic(fmt.Sprintf(\"SourceConfig.NumHotKeys must be >= 0. Got: %v\", b.cfg.HotKeyFraction))\n\t}\n\tif b.cfg.HotKeyFraction < 0 || b.cfg.HotKeyFraction > 1 {\n\t\tpanic(fmt.Sprintf(\"SourceConfig.HotKeyFraction must be a floating point number from 0 and 1. Got: %v\", b.cfg.NumHotKeys))\n\t}\n\treturn b.cfg\n}\n\n// BuildFromJSON constructs the SourceConfig by populating it with the parsed\n// JSON. Panics if there is an error in the syntax of the JSON or if the input\n// contains unknown object keys.\n//\n// An example of valid JSON object:","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/io/synthetic/source.go#L245-L281","documentation":"Panic raised by synthetic SourceConfigBuilder.Build when cfg.KeySize is zero or negative. KeySize controls generated key byte length; Build performs eager bounds checks on all fields and panics on this invalid value at configuration time.","triggerScenarios":"Building a SourceConfig without KeySize(n) or with KeySize(0) / a negative value.","commonSituations":"Benchmarks parameterizing key size from config with a 0 default, or incomplete builder chains copied from examples.","solutions":["Call builder.KeySize(n) with n >= 1 before Build().","Clamp the key-size config value to a minimum of 1.","Complete the builder chain so all size fields are set."],"exampleFix":"// before\ncfg := synthetic.NewSourceConfig().NumElements(100).ValueSize(16).Build()\n// after\ncfg := synthetic.NewSourceConfig().NumElements(100).KeySize(8).ValueSize(16).Build()","handlingStrategy":"validation","validationCode":"if keySize < 1 {\n    return fmt.Errorf(\"synthetic KeySize must be >= 1, got %d\", keySize)\n}","typeGuard":null,"tryCatchPattern":"defer func() {\n    if r := recover(); r != nil {\n        err = fmt.Errorf(\"invalid synthetic source config: %v\", r)\n    }\n}()","preventionTips":["Set KeySize explicitly whenever building a synthetic source.","Clamp config-derived key sizes to >= 1.","Unit-test SourceConfig construction from your real config format."],"tags":["go","apache-beam","synthetic-source","validation"],"backgroundTag":"value-out-of-range","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"}