{"record":{"id":"6f07b9220cbdd406","repo":"XINCGer/Unity3DTraining","slug":"full-type-name-for-target-descriptor-name-is-ta","errorCode":null,"errorMessage":"Full type name for {target.Descriptor.Name} is {target.Descriptor.FullName}; Any message's type url is {TypeUrl}","messagePattern":"Full type name for (.+?) is (.+?); Any message's type url is (.+?)","errorType":"exception","errorClass":"InvalidProtocolBufferException","httpStatus":null,"severity":"error","filePath":"NetWorkAndResources/Socket_Protobuff/Assets/Plugins/Google.Protobuf/WellKnownTypes/AnyPartial.cs","lineNumber":79,"sourceCode":"            int lastSlash = typeUrl.LastIndexOf('/');\n            return lastSlash == -1 ? \"\" : typeUrl.Substring(lastSlash + 1);\n        }\n\n        /// <summary>\n        /// Unpacks the content of this Any message into the target message type,\n        /// which must match the type URL within this Any message.\n        /// </summary>\n        /// <typeparam name=\"T\">The type of message to unpack the content into.</typeparam>\n        /// <returns>The unpacked message.</returns>\n        /// <exception cref=\"InvalidProtocolBufferException\">The target message type doesn't match the type URL in this message</exception>\n        public T Unpack<T>() where T : IMessage, new()\n        {\n            // Note: this doesn't perform as well is it might. We could take a MessageParser<T> in an alternative overload,\n            // which would be expected to perform slightly better... although the difference is likely to be negligible.\n            T target = new T();\n            if (GetTypeName(TypeUrl) != target.Descriptor.FullName)\n            {\n                throw new InvalidProtocolBufferException(\"Full type name for \" + target.Descriptor.Name + \" is \" + target.Descriptor.FullName + \"; Any message's type url is \" + TypeUrl);\n            }\n            target.MergeFrom(Value);\n            return target;\n        }\n\n        /// <summary>\n        /// Packs the specified message into an Any message using a type URL prefix of \"type.googleapis.com\".\n        /// </summary>\n        /// <param name=\"message\">The message to pack.</param>\n        /// <returns>An Any message with the content and type URL of <paramref name=\"message\"/>.</returns>\n        public static Any Pack(IMessage message)\n        {\n            return Pack(message, DefaultPrefix);\n        }\n\n        /// <summary>\n        /// Packs the specified message into an Any message using the specified type URL prefix.\n        /// </summary>","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/XINCGer/Unity3DTraining/blob/016f98412ea5e11756b286736f479b66ab6216d5/NetWorkAndResources/Socket_Protobuff/Assets/Plugins/Google.Protobuf/WellKnownTypes/AnyPartial.cs#L61-L97","documentation":"Any.Unpack<T> validates that the type URL embedded in the Any message matches T's full protobuf type name (after stripping the leading host '/'). A mismatch throws InvalidProtocolBufferException because the stored bytes cannot be safely interpreted as T. This guards against decoding an Any payload into the wrong message type.","triggerScenarios":"Calling any.Unpack<T>() where the Any was created from a different message type, where TypeUrl uses a different type name casing/namespace, or where the Any came from a service using a different package version of the type.","commonSituations":"Type renamed/moved between packages in a schema refactor so old stored Anys no longer match new type names; cross-service mismatches where producer and consumer disagree on the packed type; forgetting that Unpack<T> is strict while UnpackTo on an unknown Any is a different flow.","solutions":["Unpack to the correct type: match T to the actual type name in any.TypeUrl (inspect it before unpacking).","Use Any.GetTypeName(TypeUrl) and compare with target descriptor full names to select the right type at runtime.","Fix schema drift: regenerate/align type names (package path) between producer and consumer, or migrate stored data.","If types are equivalent but names differ, re-pack with the canonical name: Any.Pack(correctMessage)."],"exampleFix":"// before\nvar req = any.Unpack<CreateUserRequest>(); // throws if any holds a different type\n// after\nif (Any.GetTypeName(any.TypeUrl) == CreateUserRequest.Descriptor.FullName)\n    var req = any.Unpack<CreateUserRequest>();\nelse\n    /* handle unexpected type */;","handlingStrategy":"validation","validationCode":"if (Any.GetTypeName(any.TypeUrl) != typeof(T).Name &&\n    Any.GetTypeName(any.TypeUrl) != T.Descriptor.FullName)\n{\n    throw new InvalidOperationException($\"Any holds {any.TypeUrl}, not {T.Descriptor.FullName}\");\n}\nvar msg = any.Unpack<T>();","typeGuard":"bool CanUnpack<T>(Any any) where T : IMessage<T> => Any.GetTypeName(any.TypeUrl) == T.Descriptor.FullName;","tryCatchPattern":"try { return any.Unpack<T>(); } catch (InvalidProtocolBufferException ex) when (ex.Message.Contains(\"type url\")) { log.Warn($\"Any type mismatch: {ex.Message}\"); return null; }","preventionTips":["Inspect Any.TypeUrl before unpacking when the payload type can vary.","Keep proto package/type names in sync across services that exchange Any messages.","Wrap Unpack calls in a dispatch helper keyed by GetTypeName()."],"tags":["protobuf","any","well-known-types","type-mismatch"],"backgroundTag":"type-mismatch","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"}