{"record":{"id":"5f3e93b09466ec08","repo":"XINCGer/Unity3DTraining","slug":"invalid-public-dependency-index","errorCode":null,"errorMessage":"Invalid public dependency index.","messagePattern":"Invalid public dependency index\\.","errorType":"validation","errorClass":"DescriptorValidationException","httpStatus":null,"severity":"error","filePath":"NetWorkAndResources/Socket_Protobuff/Assets/Plugins/Google.Protobuf/Reflection/FileDescriptor.cs","lineNumber":103,"sourceCode":"\n        /// <summary>\n        /// Extracts public dependencies from direct dependencies. This is a static method despite its\n        /// first parameter, as the value we're in the middle of constructing is only used for exceptions.\n        /// </summary>\n        private static IList<FileDescriptor> DeterminePublicDependencies(FileDescriptor @this, FileDescriptorProto proto, FileDescriptor[] dependencies, bool allowUnknownDependencies)\n        {\n            var nameToFileMap = new Dictionary<string, FileDescriptor>();\n            foreach (var file in dependencies)\n            {\n                nameToFileMap[file.Name] = file;\n            }\n            var publicDependencies = new List<FileDescriptor>();\n            for (int i = 0; i < proto.PublicDependency.Count; i++)\n            {\n                int index = proto.PublicDependency[i];\n                if (index < 0 || index >= proto.Dependency.Count)\n                {\n                    throw new DescriptorValidationException(@this, \"Invalid public dependency index.\");\n                }\n                string name = proto.Dependency[index];\n                FileDescriptor file = nameToFileMap[name];\n                if (file == null)\n                {\n                    if (!allowUnknownDependencies)\n                    {\n                        throw new DescriptorValidationException(@this, \"Invalid public dependency: \" + name);\n                    }\n                    // Ignore unknown dependencies.\n                }\n                else\n                {\n                    publicDependencies.Add(file);\n                }\n            }\n            return new ReadOnlyCollection<FileDescriptor>(publicDependencies);\n        }","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/XINCGer/Unity3DTraining/blob/016f98412ea5e11756b286736f479b66ab6216d5/NetWorkAndResources/Socket_Protobuff/Assets/Plugins/Google.Protobuf/Reflection/FileDescriptor.cs#L85-L121","documentation":"DeterminePublicDependencies maps each index in FileDescriptorProto.PublicDependency to an entry of the Dependency list. An index that is negative or >= Dependency.Count cannot be resolved, so a DescriptorValidationException is thrown. This indicates a corrupt or malformed descriptor.","triggerScenarios":"Building a FileDescriptor from a FileDescriptorProto whose public_dependency entries reference indices outside the dependency list — typically after manual construction or corruption of the serialized descriptor bytes.","commonSituations":"Descriptor bytes hand-assembled or post-processed incorrectly; descriptors mutated by tooling; bad serialization from a third-party generator.","solutions":["Regenerate the descriptor with protoc so public_dependency indices are consistent with the dependency list.","If constructing FileDescriptorProto manually, ensure every PublicDependency index is within [0, proto.Dependency.Count).","Validate the proto before BuildFrom: check PublicDependency.All(i => i >= 0 && i < Dependency.Count).","Inspect and re-serialize the descriptor bytes if corruption is suspected."],"exampleFix":"// before\nproto.PublicDependency.Add(5); // but proto.Dependency has only 2 entries\n// after\nproto.PublicDependency.Add(1); // valid index into proto.Dependency","handlingStrategy":"validation","validationCode":"bool PublicDepsValid(FileDescriptorProto p) => p.PublicDependency.All(i => i >= 0 && i < p.Dependency.Count);","typeGuard":null,"tryCatchPattern":"try { BuildFrom(...); } catch (DescriptorValidationException e) when (e.Message == \"Invalid public dependency index.\") { log.LogError(\"Corrupt descriptor: public_dependency out of range\"); }","preventionTips":["Regenerate descriptors with protoc instead of mutating PublicDependency manually.","Validate descriptor protos before serializing/building.","Treat any manual descriptor post-processing as suspect."],"tags":["protobuf","descriptor","validation","index-out-of-range"],"backgroundTag":"index-out-of-range","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"}