{"record":{"id":"11ffb8081964e9b8","repo":"XINCGer/Unity3DTraining","slug":"typename-is-not-a-message-type","errorCode":null,"errorMessage":"\"TypeName\" is not a message type.","messagePattern":"\"TypeName\" is not a message type\\.","errorType":"validation","errorClass":"DescriptorValidationException","httpStatus":null,"severity":"error","filePath":"NetWorkAndResources/Socket_Protobuff/Assets/Plugins/Google.Protobuf/Reflection/FieldDescriptor.cs","lineNumber":325,"sourceCode":"                    if (typeDescriptor is MessageDescriptor)\n                    {\n                        fieldType = FieldType.Message;\n                    }\n                    else if (typeDescriptor is EnumDescriptor)\n                    {\n                        fieldType = FieldType.Enum;\n                    }\n                    else\n                    {\n                        throw new DescriptorValidationException(this, \"\\\"\" + Proto.TypeName + \"\\\" is not a type.\");\n                    }\n                }\n\n                if (fieldType == FieldType.Message)\n                {\n                    if (!(typeDescriptor is MessageDescriptor))\n                    {\n                        throw new DescriptorValidationException(this, \"\\\"\" + Proto.TypeName + \"\\\" is not a message type.\");\n                    }\n                    messageType = (MessageDescriptor)typeDescriptor;\n\n                    if (Proto.DefaultValue != \"\")\n                    {\n                        throw new DescriptorValidationException(this, \"Messages can't have default values.\");\n                    }\n                }\n                else if (fieldType == FieldType.Enum)\n                {\n                    if (!(typeDescriptor is EnumDescriptor))\n                    {\n                        throw new DescriptorValidationException(this, \"\\\"\" + Proto.TypeName + \"\\\" is not an enum type.\");\n                    }\n                    enumType = (EnumDescriptor)typeDescriptor;\n                }\n                else\n                {","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/XINCGer/Unity3DTraining/blob/016f98412ea5e11756b286736f479b66ab6216d5/NetWorkAndResources/Socket_Protobuff/Assets/Plugins/Google.Protobuf/Reflection/FieldDescriptor.cs#L307-L343","documentation":"During CrossLink, if the field's resolved type is FieldType.Message, the type_name must resolve to a MessageDescriptor. If the pool lookup returned an EnumDescriptor (or any other symbol), the field claims to be a message but its name names an enum, so DescriptorValidationException is thrown.","triggerScenarios":"A field with Type = TYPE_MESSAGE whose TypeName resolves to an enum in the descriptor pool — typically a proto where the field type keyword and the referenced type disagree (e.g. editing the Type enum manually in a generated FileDescriptorProto).","commonSituations":"Post-processing generated descriptors and changing Type without changing TypeName; .proto where 'message X' was converted to 'enum X' but dependents not regenerated.","solutions":["Change the field's declared type so Type = TYPE_ENUM if it references an enum (or point TypeName at a real message) and regenerate.","Regenerate all descriptors from the .proto sources so Type and TypeName stay consistent.","Validate before CrossLink: resolve TypeName and check the descriptor kind matches the declared Type."],"exampleFix":"// before (proto)\noptional MyEnum field = 1; // but Type set to TYPE_MESSAGE\n// after\noptional MyEnum field = 1; // with Type = TYPE_ENUM","handlingStrategy":"validation","validationCode":"if (field.Proto.Type == FieldDescriptorProto.Types.Type.Message)\n{\n    var sym = pool.FindSymbol(field.Proto.TypeName);\n    if (!(sym is MessageDescriptor)) throw new InvalidDataException(field.Proto.TypeName + \" is not a message\");\n}","typeGuard":"bool IsMessageField(FieldDescriptorProto f, DescriptorPool pool) =>\n    f.Type != FieldDescriptorProto.Types.Type.Message || pool.FindSymbol(f.TypeName) is MessageDescriptor;","tryCatchPattern":"try { descriptor = FileDescriptor.BuildFromByteStrings(data); }\ncatch (DescriptorValidationException ex) when (ex.Message.Contains(\"is not a message type\"))\n{ log.LogError(ex, \"Type/TypeName mismatch on field\"); }","preventionTips":["Never hand-edit Type or TypeName in generated descriptor sets; regenerate with protoc.","When a .proto type changes kind (message<->enum), regenerate all dependent descriptors.","Cross-check Type against the resolved symbol kind during descriptor import."],"tags":["protobuf","descriptor-validation","type-mismatch"],"backgroundTag":"incompatible-source-type","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"}