{"record":{"id":"f464b227fc853964","repo":"gravitational/teleport","slug":"proto-wrong-wiretype-d-for-field-usercredentia","errorCode":null,"errorMessage":"proto: wrong wireType = %d for field UserCredentials","messagePattern":"proto: wrong wireType = (.+?) for field UserCredentials","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"api/client/proto/authservice.pb.go","lineNumber":60038,"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: CreateAuthenticateChallengeRequest: wiretype end group for non-group\")\n\t\t}\n\t\tif fieldNum <= 0 {\n\t\t\treturn fmt.Errorf(\"proto: CreateAuthenticateChallengeRequest: 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 UserCredentials\", 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":60020,"sourceCodeEnd":60056,"githubUrl":"https://github.com/gravitational/teleport/blob/1283425b60ec5f60d509ba4c791183d452923ff7/api/client/proto/authservice.pb.go#L60020-L60056","documentation":"The decoder for CreateAuthenticateChallengeRequest case 1 expects field UserCredentials to have wire type 2 (length-delimited, since it is a oneof message). A different wire type was found on tag 1, so decoding aborts with this error.","triggerScenarios":"Sending CreateAuthenticateChallengeRequest where field 1 carries a non-length-delimited value (e.g. varint/fixed64) — caused by serializing a mismatched struct, hand-built bytes, or a proto where field 1 changed type.","commonSituations":"Version skew after a proto refactor moved the oneof; a test harness constructing bytes manually; message type confusion on the wire.","solutions":["Marshal the request with the generated struct and oneof setter (m.Request = &CreateAuthenticateChallengeRequest_UserCredentials{...}) instead of hand-crafted bytes","Confirm both sides use identical proto definitions for field 1","Check that the bytes are not from a different message type","Re-run codegen (protoc/gogo) so generated Unmarshal matches the schema"],"exampleFix":"// before\n// manually appended varint for field 1\nbuf = append(buf, 0x08, 0x01)\n// after\nreq := &proto.CreateAuthenticateChallengeRequest{\n  Request: &proto.CreateAuthenticateChallengeRequest_UserCredentials{\n    UserCredentials: &proto.UserCredentials{...},\n  },\n}\nb, _ := req.Marshal()","handlingStrategy":"validation","validationCode":"// ensure the oneof is set via the generated wrapper before sending\nif req.GetRequest() == nil { return errors.New(\"Request oneof must be set\") }\nif _, ok := req.Request.(*proto.CreateAuthenticateChallengeRequest_UserCredentials); !ok && req.GetRecoveryStartTokenID() == \"\" && req.GetContextUser() == nil && req.GetPasswordless() == nil {\n  return errors.New(\"expected UserCredentials variant\")\n}","typeGuard":"func isUserCredentials(r *proto.CreateAuthenticateChallengeRequest) bool {\n  _, ok := r.GetRequest().(*proto.CreateAuthenticateChallengeRequest_UserCredentials)\n  return ok\n}","tryCatchPattern":null,"preventionTips":["Construct requests only through generated struct fields and oneof wrappers","Never hand-encode protobuf wire bytes","Keep proto field types stable; retype via new fields, not in place","Run round-trip Marshal/Unmarshal tests in CI"],"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"}