{"record":{"id":"4e95b31ec3c0e8eb","repo":"apache/beam","slug":"received-unknown-value-type-want-a-number-got-t","errorCode":null,"errorMessage":"received unknown value type: want a number:, got %T","messagePattern":"received unknown value type: want a number:, got %T","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/exec/hash.go","lineNumber":166,"sourceCode":"\t\tval = uint64(n)\n\tcase int64:\n\t\tval = uint64(n)\n\tcase uint:\n\t\tval = uint64(n)\n\tcase uint8:\n\t\tval = uint64(n)\n\tcase uint16:\n\t\tval = uint64(n)\n\tcase uint32:\n\t\tval = uint64(n)\n\tcase uint64:\n\t\tval = n\n\tcase float64:\n\t\tval = math.Float64bits(n)\n\tcase float32:\n\t\tval = uint64(math.Float64bits(float64(n)))\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"received unknown value type: want a number:, got %T\", n))\n\t}\n\tbinary.LittleEndian.PutUint64(h.cache, val)\n\th.hash.Write(h.cache)\n\th.we.EncodeSingle(w, h.hash)\n\treturn h.hash.Sum64(), nil\n}\n\ntype rowHasher struct {\n\thash  hash.Hash64\n\tcoder ElementEncoder\n\twe    WindowEncoder\n\tfv    FullValue\n}\n\nfunc (h *rowHasher) Hash(element any, w typex.Window) (uint64, error) {\n\th.hash.Reset()\n\th.fv.Elm = element\n\tif err := h.coder.Encode(&h.fv, h.hash); err != nil {","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/exec/hash.go#L148-L184","documentation":"The deterministic hash for transform inputs only knows how to hash numeric types (ints, uints, floats) by converting them to uint64 bits. Any other value type reaching Hash hits the default case and panics. This is an internal type-support limitation of the hasher.","triggerScenarios":"Hashing an element during potential-key re-hashing where the key component's dynamic type is not a numeric kind (e.g. a struct, string, or interface the switch doesn't handle) inside ProcessElement/Encode paths that use hash.go.","commonSituations":"Element coder/type changes so a non-number lands in the hash path; using custom types as elements that aren't reduced to plain numbers before hashing; Beam version differences in what gets hashed.","solutions":["Ensure only numeric types reach the hash path — convert/coerce the value to int64/uint64/float64 before hashing.","If hashing custom structs, provide or use a coder path that hashes fields individually as numbers.","Check whether an upstream conversion step was dropped, causing a raw value to be hashed."],"exampleFix":"// before\nHash(v any) // panics when v is, e.g., a struct\n// after\nswitch n := v.(type) {\ncase int64, uint64, float64:\n\tHash(v)\ndefault:\n\t// encode via type-specific hashing or reject earlier\n}","handlingStrategy":"type-guard","validationCode":"switch v.(type) {\ncase int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64, float32, float64:\n\t// ok\ndefault:\n\treturn fmt.Errorf(\"cannot hash non-numeric value %T\", v)\n}","typeGuard":"func isHashableNumber(v any) bool {\n\tswitch v.(type) {\n\tcase int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64, float32, float64:\n\t\treturn true\n\t}\n\treturn false\n}","tryCatchPattern":null,"preventionTips":["Only route numeric element types through the hash path.","Convert custom key types to their numeric representation before hashing.","Review element coders after schema changes to ensure the hashed component stays numeric."],"tags":["go","panic","beam","hash","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}