{"record":{"id":"9b470f84c26ecdbc","repo":"gravitational/teleport","slug":"proto-wrong-wiretype-d-for-field-browsermfareq","errorCode":null,"errorMessage":"proto: wrong wireType = %d for field BrowserMFARequestID","messagePattern":"proto: wrong wireType = (.+?) for field BrowserMFARequestID","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"api/client/proto/authservice.pb.go","lineNumber":60343,"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.BrowserMFATSHRedirectURL = string(dAtA[iNdEx:postIndex])\n\t\t\tiNdEx = postIndex\n\t\tcase 10:\n\t\t\tif wireType != 2 {\n\t\t\t\treturn fmt.Errorf(\"proto: wrong wireType = %d for field BrowserMFARequestID\", 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":60325,"sourceCodeEnd":60361,"githubUrl":"https://github.com/gravitational/teleport/blob/1283425b60ec5f60d509ba4c791183d452923ff7/api/client/proto/authservice.pb.go#L60325-L60361","documentation":"Generated Unmarshal code expects field 10 (BrowserMFARequestID, a string) to be wire type 2. The incoming bytes use a different wire type for tag 10, so the decoder returns this error and stops. It signals that the payload does not match the compiled message schema.","triggerScenarios":"Unmarshaling bytes where field 10 of the MFA-capable message is not length-delimited — commonly after schema evolution renumbered fields, so an old encoder puts different data at tag 10 than the new decoder expects.","commonSituations":"Rolling upgrades where auth service and clients temporarily disagree on the proto schema; messages persisted before a schema change and re-read after; a non-teleport producer emitting incorrect tags; corrupted frames.","solutions":["Upgrade/downgrade so both peers share one generated authservice.pb.go (same proto field numbering)","Migrate or discard serialized messages persisted under the old schema","Validate the payload with protoc --decode_raw before unmarshaling in custom pipelines","Ensure only proto.Marshal output reaches Unmarshal (no manual byte building)"],"exampleFix":"// before: reading old persisted bytes\nold, _ := os.ReadFile(\"mfa_state.bin\")\nproto.Unmarshal(old, msg)\n// after: persist a versioned envelope and re-encode on upgrade\nif schemaVer < 2 { old = migrateToV2(old) }\nerr := proto.Unmarshal(old, msg)","handlingStrategy":"validation","validationCode":"func schemaVersion(v int) error {\n    if v < currentSchemaVersion {\n        return fmt.Errorf(\"payload schema v%d < required v%d; re-serialize before decode\", v, currentSchemaVersion)\n    }\n    return nil\n}","typeGuard":"func isWireTypeMismatch(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"wrong wireType = \")\n}","tryCatchPattern":"if err := proto.Unmarshal(stored, &state); err != nil {\n    if isWireTypeMismatch(err) {\n        stored = migrateStoredState(stored) // re-encode from old schema\n        err = proto.Unmarshal(stored, &state)\n    }\n    if err != nil { return trace.Wrap(err) }\n}","preventionTips":["Version-stamp persisted protobuf state and migrate before decode","Roll schema changes with coordinated upgrades","Never parse in the middle of a buffer; unmarshal from message boundaries","Test decode compatibility between old and new schema versions in CI"],"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"}