{"record":{"id":"6bed61e2e0150b76","repo":"apache/beam","slug":"sourceconfig-numhotkeys-must-be-0-got-v","errorCode":null,"errorMessage":"SourceConfig.NumHotKeys must be >= 0. Got: %v","messagePattern":"SourceConfig\\.NumHotKeys must be >= 0\\. Got: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/io/synthetic/source.go","lineNumber":269,"sourceCode":"\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:\n//\n//\t{\n//\t\t \"num_records\": 5,\n//\t\t \"key_size\": 5,\n//\t\t \"value_size\": 5,\n//\t\t \"num_hot_keys\": 5,","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/io/synthetic/source.go#L251-L287","documentation":"Build panics when NumHotKeys is negative. Hot-key count is optional (0 means no hot keys) but must not be negative; note the panic message incorrectly prints HotKeyFraction's value, a known quirk in the source.","triggerScenarios":"Building a SourceConfig with NumHotKeys(-1) or any negative value, typically from a miscomputed or misconfigured integer.","commonSituations":"Skew simulations where hot-key count or fraction fields were swapped or negated in YAML/flag parsing.","solutions":["Set builder.NumHotKeys(n) with n >= 0 (or omit it entirely, defaulting to 0).","Check that hot-key and hot-key-fraction config fields are not transposed or negated.","Validate the config's non-negative integer fields before building the source."],"exampleFix":"// before\ncfg := synthetic.NewSourceConfig().NumHotKeys(-1).Build()\n// after\nhotKeys := cfg.HotKeys\nif hotKeys < 0 {\n    hotKeys = 0\n}\ncfg2 := synthetic.NewSourceConfig().NumHotKeys(hotKeys).Build()","handlingStrategy":"validation","validationCode":"if numHotKeys < 0 {\n    return fmt.Errorf(\"synthetic NumHotKeys must be >= 0, got %d\", numHotKeys)\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":["Remember NumHotKeys defaults to 0; omit it rather than computing negative values.","Clamp skew/hot-key parameters parsed from config to >= 0.","Watch out for swapped NumHotKeys/HotKeyFraction fields when configuring skew."],"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"}