{"record":{"id":"16101fdd640adf9b","repo":"gravitational/teleport","slug":"proto-wrong-wiretype-d-for-field-tokenid","errorCode":null,"errorMessage":"proto: wrong wireType = %d for field TokenID","messagePattern":"proto: wrong wireType = (.+?) for field TokenID","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"api/client/proto/authservice.pb.go","lineNumber":60513,"sourceCode":"\t\t\tb := dAtA[iNdEx]\n\t\t\tiNdEx++\n\t\t\twire |= uint64(b&0x7F) << shift\n\t\t\tif b < 0x80 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tfieldNum := int32(wire >> 3)\n\t\twireType := int(wire & 0x7)\n\t\tif wireType == 4 {\n\t\t\treturn fmt.Errorf(\"proto: CreateRegisterChallengeRequest: wiretype end group for non-group\")\n\t\t}\n\t\tif fieldNum <= 0 {\n\t\t\treturn fmt.Errorf(\"proto: CreateRegisterChallengeRequest: illegal tag %d (wire type %d)\", fieldNum, wire)\n\t\t}\n\t\tswitch fieldNum {\n\t\tcase 1:\n\t\t\tif wireType != 2 {\n\t\t\t\treturn fmt.Errorf(\"proto: wrong wireType = %d for field TokenID\", wireType)\n\t\t\t}\n\t\t\tvar stringLen uint64\n\t\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\t\tif shift >= 64 {\n\t\t\t\t\treturn ErrIntOverflowAuthservice\n\t\t\t\t}\n\t\t\t\tif iNdEx >= l {\n\t\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t\t}\n\t\t\t\tb := dAtA[iNdEx]\n\t\t\t\tiNdEx++\n\t\t\t\tstringLen |= uint64(b&0x7F) << shift\n\t\t\t\tif b < 0x80 {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tintStringLen := int(stringLen)\n\t\t\tif intStringLen < 0 {","sourceCodeStart":60495,"sourceCodeEnd":60531,"githubUrl":"https://github.com/gravitational/teleport/blob/1283425b60ec5f60d509ba4c791183d452923ff7/api/client/proto/authservice.pb.go#L60495-L60531","documentation":"Field 1 of CreateRegisterChallengeRequest is TokenID, a string that must be wire type 2 (length-delimited). The incoming bytes carry tag 1 with a different wire type, so the generated Unmarshal returns this error, indicating schema mismatch or malformed input.","triggerScenarios":"Bytes where field 1 of CreateRegisterChallengeRequest is not length-delimited — e.g. an encoder that emits TokenID as a varint, or an older/newer schema where field 1 held a different scalar — during register-challenge RPCs.","commonSituations":"Version skew between teleport client and auth service proto definitions; custom integration scripts crafting raw bytes; corrupted gRPC frames; decoding a different request type's bytes as CreateRegisterChallengeRequest.","solutions":["Align the api/client/proto generated code on both client and server","Construct the request via the typed struct and marshal with proto.Marshal","Confirm tag 1's wire type with protoc --decode_raw when diagnosing","Check for middleboxes or caches that could alter binary payloads in transit"],"exampleFix":"// before: manual bytes for the request\nraw := []byte{0x08, 0x2A} // TokenID as varint\n// after\nreq := &proto.CreateRegisterChallengeRequest{TokenID: tokID}\nraw, err := proto.Marshal(req)","handlingStrategy":"try-catch","validationCode":"func tokenIDFieldIsValid(b []byte) bool {\n    if len(b) == 0 { return false }\n    tag, n := binary.Uvarint(b)\n    return n > 0 && tag>>3 == 1 && tag&0x7 == 2\n}","typeGuard":"func isWireTypeMismatch(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"wrong wireType = \")\n}","tryCatchPattern":"req := &proto.CreateRegisterChallengeRequest{}\nif err := proto.Unmarshal(blob, req); err != nil {\n    if isWireTypeMismatch(err) {\n        return trace.BadParameter(\"register challenge payload from incompatible schema; upgrade peer\")\n    }\n    return trace.Wrap(err)\n}","preventionTips":["Use typed structs + proto.Marshal; never assemble request bytes manually","Keep api/client/proto generated code in sync across all binaries","Verify interop between client versions before rolling auth service upgrades","Inspect unexpected payloads with protoc --decode_raw before filing bugs"],"tags":["protobuf","grpc","wire-format","deserialization"],"backgroundTag":"proto-wire-type-mismatch","analyzedSha":"1283425b60ec5f60d509ba4c791183d452923ff7","analyzedAt":"2026-09-02T04:06:41.601Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}