{"record":{"id":"9ec699a7d08b0f8a","repo":"apache/beam","slug":"sourceconfig-hotkeyfraction-must-be-a-floating-point-number","errorCode":null,"errorMessage":"SourceConfig.HotKeyFraction must be a floating point number from 0 and 1. Got: %v","messagePattern":"SourceConfig\\.HotKeyFraction must be a floating point number from 0 and 1\\. Got: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/io/synthetic/source.go","lineNumber":272,"sourceCode":"// 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,\n//\t}\nfunc (b *SourceConfigBuilder) BuildFromJSON(jsonData []byte) SourceConfig {\n\tdecoder := json.NewDecoder(bytes.NewReader(jsonData))","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/io/synthetic/source.go#L254-L290","documentation":"SourceConfigBuilder.Build() in the Beam Go synthetic source panics when HotKeyFraction is outside the [0,1] range. The synthetic source uses this fraction to control how many records come from hot keys, so a fraction below 0 or above 1 is meaningless. Note the source region shows a copy-paste bug in the library itself: the panic message formats cfg.NumHotKeys instead of cfg.HotKeyFraction, so the reported value in the message will be wrong.","triggerScenarios":"Calling SourceConfigBuilder.Build() after setting HotKeyFraction to a negative value or a value greater than 1 (e.g. via builder.HotKeyFraction(1.5) or negative values in JSON-driven configs).","commonSituations":"Passing a percentage like 50 instead of 0.5; computing a fraction with integer division that yields a bad value; hand-writing synthetic source JSON in a pipeline template with an out-of-range fraction; typos swapping NumHotKeys and HotKeyFraction fields.","solutions":["Clamp or validate HotKeyFraction to [0,1] before calling Build(), e.g. if f < 0 || f > 1 { return error }.","If the value came from a percentage, divide by 100 (50 -> 0.5).","Check that you did not accidentally set HotKeyFraction where you meant NumHotKeys (or vice versa), since the panic message itself misreports the value due to a formatting bug."],"exampleFix":"// before\nb.HotKeyFraction(50) // meant 50%\n// after\nb.HotKeyFraction(0.5)","handlingStrategy":"validation","validationCode":"if cfg.HotKeyFraction < 0 || cfg.HotKeyFraction > 1 {\n    return fmt.Errorf(\"HotKeyFraction must be in [0,1], got %v\", cfg.HotKeyFraction)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate fractions in your config-loading layer before building pipeline components.","Remember percentages must be converted to fractions (50 -> 0.5).","Write a unit test for every synthetic-source config template."],"tags":["go","apache-beam","config-validation","panic"],"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"}