{"record":{"id":"16771bc2c0788c3f","repo":"XINCGer/Unity3DTraining","slug":"no-such-field-number","errorCode":null,"errorMessage":"No such field number","messagePattern":"No such field number","errorType":"exception","errorClass":"KeyNotFoundException","httpStatus":null,"severity":"error","filePath":"NetWorkAndResources/Socket_Protobuff/Assets/Plugins/Google.Protobuf/Reflection/MessageDescriptor.cs","lineNumber":324,"sourceCode":"            {\n                return messageDescriptor.jsonFieldMap;\n            }\n\n            /// <summary>\n            /// Retrieves the descriptor for the field with the given number.\n            /// </summary>\n            /// <param name=\"number\">Number of the field to retrieve the descriptor for</param>\n            /// <returns>The accessor for the given field</returns>\n            /// <exception cref=\"KeyNotFoundException\">The message descriptor does not contain a field\n            /// with the given number</exception>\n            public FieldDescriptor this[int number]\n            {\n                get\n                {\n                    var fieldDescriptor = messageDescriptor.FindFieldByNumber(number);\n                    if (fieldDescriptor == null)\n                    {\n                        throw new KeyNotFoundException(\"No such field number\");\n                    }\n                    return fieldDescriptor;\n                }\n            }\n\n            /// <summary>\n            /// Retrieves the descriptor for the field with the given name.\n            /// </summary>\n            /// <param name=\"name\">Name of the field to retrieve the descriptor for</param>\n            /// <returns>The descriptor for the given field</returns>\n            /// <exception cref=\"KeyNotFoundException\">The message descriptor does not contain a field\n            /// with the given name</exception>\n            public FieldDescriptor this[string name]\n            {\n                get\n                {\n                    var fieldDescriptor = messageDescriptor.FindFieldByName(name);\n                    if (fieldDescriptor == null)","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/XINCGer/Unity3DTraining/blob/016f98412ea5e11756b286736f479b66ab6216d5/NetWorkAndResources/Socket_Protobuff/Assets/Plugins/Google.Protobuf/Reflection/MessageDescriptor.cs#L306-L342","documentation":"MessageDescriptor.Fields indexer by number looks up the field via FindFieldByNumber and throws KeyNotFoundException with 'No such field number' when no field with that number exists in the message. It is the dictionary-style contract of the FieldCollection indexer.","triggerScenarios":"Accessing descriptor.Fields[number] where the number is not defined in the message — e.g. reading a field number from an unknown/wire-decoded context, or assuming a field exists across schema versions.","commonSituations":"Schema drift: code referencing a field number from an older/newer .proto version; iterating extension or unknown field numbers and probing Fields; hand-written reflection code with off-by-one or wrong field numbers.","solutions":["Use FindFieldByNumber(number) and null-check instead of the throwing indexer when the field may not exist.","Verify the field number against the current .proto / generated code for the message.","Ensure client and server use matching schema versions so the expected field number exists.","Check that you're inspecting the correct MessageDescriptor (right message type)."],"exampleFix":"// before\nvar field = descriptor.Fields[42]; // KeyNotFoundException if absent\n// after\nvar field = descriptor.FindFieldByNumber(42);\nif (field != null) { /* use field */ }","handlingStrategy":"validation","validationCode":"var field = descriptor.FindFieldByNumber(number); if (field == null) { /* handle missing field */ }","typeGuard":"bool HasFieldNumber(MessageDescriptor d, int n) => d.FindFieldByNumber(n) != null;","tryCatchPattern":"try { var f = descriptor.Fields[number]; } catch (KeyNotFoundException) { field = null; /* unknown field — skip or fall back */ }","preventionTips":["Prefer FindFieldByNumber over the throwing Fields indexer for optional lookups.","Keep schema versions synchronized between producers and consumers.","Check field numbers against generated code constants, not magic numbers."],"tags":["protobuf","reflection","descriptor","key-not-found"],"backgroundTag":"record-not-found","analyzedSha":"016f98412ea5e11756b286736f479b66ab6216d5","analyzedAt":"2026-09-12T01:08:58.711Z","contentChangedAt":"2026-09-12T01:08:58.711Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}