{"record":{"id":"337a1bf9764c55cd","repo":"temporalio/temporal","slug":"unknown-number-type-v","errorCode":null,"errorMessage":"unknown number type: %v","messagePattern":"unknown number type: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/number/number.go","lineNumber":95,"sourceCode":"\t\tnumberType: numberType,\n\t\tvalue:      number,\n\t}\n}\n\nfunc (n Number) GetIntOrDefault(\n\tdefaultValue int,\n) int {\n\tswitch n.numberType {\n\tcase TypeFloat:\n\t\treturn int(n.value.(float64))\n\tcase TypeInt:\n\t\treturn n.value.(int)\n\tcase TypeUint:\n\t\treturn int(n.value.(uint))\n\tcase TypeUnknown:\n\t\treturn defaultValue\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"unknown number type: %v\", n.numberType))\n\t}\n}\n\nfunc (n Number) GetUintOrDefault(\n\tdefaultValue uint,\n) uint {\n\tswitch n.numberType {\n\tcase TypeFloat:\n\t\treturn uint(n.value.(float64))\n\tcase TypeInt:\n\t\treturn uint(n.value.(int))\n\tcase TypeUint:\n\t\treturn n.value.(uint)\n\tcase TypeUnknown:\n\t\treturn defaultValue\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"unknown number type: %v\", n.numberType))\n\t}","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/common/number/number.go#L77-L113","documentation":"Number.GetIntOrDefault converts the wrapped value to int. TypeUnknown and recognized types return values/default, but any other internal numberType value means the Number was constructed with an unregistered type, and the library panics. It is an internal-invariant violation: valid Numbers always carry TypeInt, TypeUint, or TypeUnknown.","triggerScenarios":"Calling GetIntOrDefault on a Number whose numberType is neither TypeInt, TypeUint, nor TypeUnknown — e.g. a Number built by a constructor or deserializer that set numberType to an unregistered value.","commonSituations":"Adding a new number type (e.g. float) to the package without updating every getter's switch; hand-constructing Number structs instead of using the provided New* constructors.","solutions":["Construct Numbers only via the package's exported New* functions","If a new number type was added, add a matching case to GetIntOrDefault's switch","Inspect how the Number was produced (deserialization path) and fix the type registration there"],"exampleFix":"// before\ndefault:\n\tpanic(fmt.Sprintf(\"unknown number type: %v\", n.numberType))\n// after\ncase TypeFloat:\n\treturn int(n.value.(float64))\ndefault:\n\treturn defaultValue // log instead of panicking","handlingStrategy":"type-guard","validationCode":"func isGetIntSafe(n number.Number) bool { return true } // getter is total for valid Numbers; validate at construction instead","typeGuard":"func validNumber(n number.Number) bool {\n\tswitch n.NumberType() {\n\tcase number.TypeInt, number.TypeUint, number.TypeUnknown:\n\t\treturn true\n\t}\n\treturn false\n}","tryCatchPattern":null,"preventionTips":["Construct Numbers only via the package's New* constructors","When adding a new number type, update every getter switch (GetInt/GetUint/GetFloatOrDefault) in the same change","Never build Number struct literals manually"],"tags":["go","panic","type-switch","invariant"],"backgroundTag":"unknown-number-type","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}