{"record":{"id":"1c660f0d0a9d31aa","repo":"apache/beam","slug":"not-a-unsigned-integer-type-v","errorCode":null,"errorMessage":"not a unsigned integer type: %v","messagePattern":"not a unsigned integer type: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/coderx/varint.go","lineNumber":46,"sourceCode":"// NewVarIntZ returns a varint coder for the given integer type. It uses a zig-zag scheme,\n// which is _different_ from the Beam standard coding scheme.\nfunc NewVarIntZ(t reflect.Type) (*coder.CustomCoder, error) {\n\tswitch t.Kind() {\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\treturn coder.NewCustomCoder(\"varintz\", t, encVarIntZ, decVarIntZ)\n\tdefault:\n\t\treturn nil, errors.Errorf(\"not a signed integer type: %v\", t)\n\t}\n}\n\n// NewVarUintZ returns a uvarint coder for the given integer type. It uses a zig-zag scheme,\n// which is _different_ from the Beam standard coding scheme.\nfunc NewVarUintZ(t reflect.Type) (*coder.CustomCoder, error) {\n\tswitch t.Kind() {\n\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:\n\t\treturn coder.NewCustomCoder(\"varuintz\", t, encVarUintZ, decVarUintZ)\n\tdefault:\n\t\treturn nil, errors.Errorf(\"not a unsigned integer type: %v\", t)\n\t}\n}\n\nfunc encVarIntZ(v typex.T) []byte {\n\tvar val int64\n\tswitch n := v.(type) {\n\tcase int:\n\t\tval = int64(n)\n\tcase int8:\n\t\tval = int64(n)\n\tcase int16:\n\t\tval = int64(n)\n\tcase int32:\n\t\tval = int64(n)\n\tcase int64:\n\t\tval = n\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"received unknown value type: want a signed integer:, got %T\", n))","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/coderx/varint.go#L28-L64","documentation":"Error returned by NewVarUintZ when asked for a zig-zag uvarint coder for a type whose reflect.Kind is not an unsigned integer (Uint..Uintptr). The constructor only supports unsigned kinds; passing a signed or non-integer type (the adjacent NewVarIntZ handles signed types) hits this guard. Typically reached via coder inference on a struct field of unsupported type.","triggerScenarios":"Calling coderx.NewVarUintZ(t) with a signed integer, float, or non-numeric reflect.Type; typically from inferCoder with a mismatched field type.","commonSituations":"Passing int/int64 to the uint coder; copying a coder registration from a signed field to an unsigned one without updating the constructor.","solutions":["Use NewVarIntZ for signed integer kinds instead.","Pass an unsigned integer type such as reflect.TypeOf(uint64(0)).","Audit coder registrations so each field's Kind matches the coder constructor used."],"exampleFix":"// before\nc, err := coderx.NewVarUintZ(reflect.TypeOf(int64(0)))\n// after\nc, err := coderx.NewVarIntZ(reflect.TypeOf(int64(0)))","handlingStrategy":"type-guard","validationCode":"func canUseVarUintZ(t reflect.Type) bool {\n    switch t.Kind() {\n    case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:\n        return true\n    }\n    return false\n}","typeGuard":"func isUnsignedIntKind(t reflect.Type) bool {\n    k := t.Kind()\n    return k >= reflect.Uint && k <= reflect.Uint64\n}","tryCatchPattern":"c, err := coderx.NewVarUintZ(t)\nif err != nil {\n    return fmt.Errorf(\"expected unsigned int type, got %s: %w\", t, err)\n}","preventionTips":["Check t.Kind() before constructing the coder; signed types belong in NewVarIntZ.","Keep one coder-selection function for the project to avoid duplicated mismatched calls.","Test inferCoder paths with every integer width used in your schema."],"tags":["go","apache-beam","coder","type-mismatch","reflect"],"backgroundTag":"incompatible-source-type","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"}