{"record":{"id":"274f533dac884d35","repo":"gravitational/teleport","slug":"proto-wrong-wiretype-d-for-field-contextuser","errorCode":null,"errorMessage":"proto: wrong wireType = %d for field ContextUser","messagePattern":"proto: wrong wireType = (.+?) for field ContextUser","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"api/client/proto/authservice.pb.go","lineNumber":60105,"sourceCode":"\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 {\n\t\t\t\treturn ErrInvalidLengthAuthservice\n\t\t\t}\n\t\t\tpostIndex := iNdEx + intStringLen\n\t\t\tif postIndex < 0 {\n\t\t\t\treturn ErrInvalidLengthAuthservice\n\t\t\t}\n\t\t\tif postIndex > l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tm.Request = &CreateAuthenticateChallengeRequest_RecoveryStartTokenID{string(dAtA[iNdEx:postIndex])}\n\t\t\tiNdEx = postIndex\n\t\tcase 3:\n\t\t\tif wireType != 2 {\n\t\t\t\treturn fmt.Errorf(\"proto: wrong wireType = %d for field ContextUser\", wireType)\n\t\t\t}\n\t\t\tvar msglen int\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\tmsglen |= int(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\tif msglen < 0 {\n\t\t\t\treturn ErrInvalidLengthAuthservice","sourceCodeStart":60087,"sourceCodeEnd":60123,"githubUrl":"https://github.com/gravitational/teleport/blob/1283425b60ec5f60d509ba4c791183d452923ff7/api/client/proto/authservice.pb.go#L60087-L60123","documentation":"Protobuf unmarshal guard in generated code: while decoding CreateAuthenticateChallengeRequest, the ContextUser oneof field arrived with an unexpected wire type instead of the length-delimited type expected for a message.","triggerScenarios":"Bytes where tag 3 is not length-delimited — produced by serializing an incompatible struct, hand-built bytes, or cross-version field type changes.","commonSituations":"Mixed client/server versions after the oneof was reshaped; corrupted stream; message-type confusion in a test or proxy.","solutions":["Use the generated oneof wrapper CreateAuthenticateChallengeRequest_ContextUser when building the request","Align proto definitions and regenerate code on both sides","Verify the payload belongs to CreateAuthenticateChallengeRequest","Validate the raw bytes with protoc --decode_raw"],"exampleFix":"// before\nm.Field = 3 // manual tagging\n// after\nm.Request = &proto.CreateAuthenticateChallengeRequest_ContextUser{ContextUser: &proto.ContextUser{User: \"alice\"}}","handlingStrategy":"type-guard","validationCode":"if req.GetContextUser() == nil && req.GetRequest() == nil { return errors.New(\"no request variant set\") }","typeGuard":"func isContextUser(r *proto.CreateAuthenticateChallengeRequest) (*proto.ContextUser, bool) {\n  v, ok := r.GetRequest().(*proto.CreateAuthenticateChallengeRequest_ContextUser)\n  if !ok { return nil, false }\n  return v.ContextUser, true\n}","tryCatchPattern":null,"preventionTips":["Use the generated oneof wrapper types when assigning Request","Keep oneof field numbers reserved across refactors","Rebuild all services together when oneofs change shape","Prefer Marshal/Unmarshal round-trip tests over manual byte fixtures"],"tags":["protobuf","grpc","oneof","wire-format"],"backgroundTag":"protobuf-wire-type-mismatch","analyzedSha":"1283425b60ec5f60d509ba4c791183d452923ff7","analyzedAt":"2026-09-02T04:06:41.601Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}