{"record":{"id":"cec7629cbc25ad31","repo":"XINCGer/Unity3DTraining","slug":"invalid-embedded-descriptor-for-proto-name","errorCode":null,"errorMessage":"Invalid embedded descriptor for \"{proto.Name}\".","messagePattern":"Invalid embedded descriptor for \"(.+?)\"\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"NetWorkAndResources/Socket_Protobuff/Assets/Plugins/Google.Protobuf/Reflection/FileDescriptor.cs","lineNumber":327,"sourceCode":"            FileDescriptorProto proto;\n            try\n            {\n                proto = FileDescriptorProto.Parser.ParseFrom(descriptorData);\n            }\n            catch (InvalidProtocolBufferException e)\n            {\n                throw new ArgumentException(\"Failed to parse protocol buffer descriptor for generated code.\", e);\n            }\n\n            try\n            {\n                // When building descriptors for generated code, we allow unknown\n                // dependencies by default.\n                return BuildFrom(ByteString.CopyFrom(descriptorData), proto, dependencies, true, generatedCodeInfo);\n            }\n            catch (DescriptorValidationException e)\n            {\n                throw new ArgumentException(\"Invalid embedded descriptor for \\\"\" + proto.Name + \"\\\".\", e);\n            }\n        }\n\n        /// <summary>\n        /// Returns a <see cref=\"System.String\" /> that represents this instance.\n        /// </summary>\n        /// <returns>\n        /// A <see cref=\"System.String\" /> that represents this instance.\n        /// </returns>\n        public override string ToString()\n        {\n            return \"FileDescriptor for \" + Name;\n        }\n\n        /// <summary>\n        /// Returns the file descriptor for descriptor.proto.\n        /// </summary>\n        /// <remarks>","sourceCodeStart":309,"sourceCodeEnd":345,"githubUrl":"https://github.com/XINCGer/Unity3DTraining/blob/016f98412ea5e11756b286736f479b66ab6216d5/NetWorkAndResources/Socket_Protobuff/Assets/Plugins/Google.Protobuf/Reflection/FileDescriptor.cs#L309-L345","documentation":"If building the file descriptor from embedded data raises a DescriptorValidationException, FromGeneratedCode wraps it in an ArgumentException naming the proto file. The root cause is any descriptor validation failure (bad field types, missing types, dependency mismatch, etc.) inside the embedded descriptor of generated code.","triggerScenarios":"FromGeneratedCode where CrossLink or validation fails: missing type_name, unknown dependency with allowUnknownDependencies=false mismatch, dependency count mismatch, or referencing a type not present in the descriptor set.","commonSituations":"Mixed generated files from different schema versions; a generated file's dependencies array missing an imported descriptor; hand-edited generated code; descriptor bytes generated from a .proto inconsistent with its imports.","solutions":["Inspect the inner DescriptorValidationException (ArgumentException.InnerException) for the real cause.","Regenerate ALL dependent .cs files from the current .proto files in one protoc run.","Ensure every imported file's descriptor is passed in the dependencies argument.","Diff the embedded descriptor bytes against a freshly generated descriptor to find the divergence."],"exampleFix":"// before\ntry { var fd = FileDescriptor.FromGeneratedCode(data, deps, msgs); } catch (ArgumentException e) { /* only outer message visible */ }\n// after\ncatch (ArgumentException e) { throw new InvalidOperationException(\"Root cause: \" + e.InnerException?.Message, e); } // surface real validation error","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { FromGeneratedCode(...); } catch (ArgumentException e) { var root = e.InnerException as DescriptorValidationException; log.LogError($\"Descriptor for {root?.Descriptor?.Name}: {root?.Message}\"); }","preventionTips":["Always inspect InnerException to find the underlying validation failure.","Regenerate the full descriptor set and all generated files in one run.","Validate descriptors in CI before shipping assemblies."],"tags":["protobuf","descriptor","reflection","code-generation"],"backgroundTag":"schema-validation-failed","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"}