{"record":{"id":"edf8ac84a325c1af","repo":"EllanJiang/GameFramework","slug":"name-is-invalid-resourcepackversionlist-resource","errorCode":null,"errorMessage":"Name is invalid.","messagePattern":"Name is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourcePackVersionList.Resource.cs","lineNumber":46,"sourceCode":"            private readonly int m_CompressedHashCode;\n\n            /// <summary>\n            /// 初始化资源的新实例。\n            /// </summary>\n            /// <param name=\"name\">资源名称。</param>\n            /// <param name=\"variant\">资源变体名称。</param>\n            /// <param name=\"extension\">资源扩展名称。</param>\n            /// <param name=\"loadType\">资源加载方式。</param>\n            /// <param name=\"offset\">资源偏移。</param>\n            /// <param name=\"length\">资源长度。</param>\n            /// <param name=\"hashCode\">资源哈希值。</param>\n            /// <param name=\"compressedLength\">资源压缩后长度。</param>\n            /// <param name=\"compressedHashCode\">资源压缩后哈希值。</param>\n            public Resource(string name, string variant, string extension, byte loadType, long offset, int length, int hashCode, int compressedLength, int compressedHashCode)\n            {\n                if (string.IsNullOrEmpty(name))\n                {\n                    throw new GameFrameworkException(\"Name is invalid.\");\n                }\n\n                m_Name = name;\n                m_Variant = variant;\n                m_Extension = extension;\n                m_LoadType = loadType;\n                m_Offset = offset;\n                m_Length = length;\n                m_HashCode = hashCode;\n                m_CompressedLength = compressedLength;\n                m_CompressedHashCode = compressedHashCode;\n            }\n\n            /// <summary>\n            /// 获取资源名称。\n            /// </summary>\n            public string Name\n            {","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourcePackVersionList.Resource.cs#L28-L64","documentation":"The Resource class nested in ResourcePackVersionList validates the resource name in its constructor. Since every packed resource must be identified by name, a null or empty name makes the record meaningless, so a GameFrameworkException is thrown at construction time. This protects the in-memory pack version list from malformed entries.","triggerScenarios":"Constructing ResourcePackVersionList.Resource directly, or deserializing/parsing a resource-pack version list whose resource entry has a null or empty name field.","commonSituations":"A corrupted or hand-edited resource pack version file, a packaging tool that omitted the name, or partial binary data producing an empty string during deserialization.","solutions":["Pass a valid non-empty resource name to the Resource constructor","Regenerate the resource pack version list with the packaging pipeline","Fix the deserialization/builder code so the name field is populated"],"exampleFix":"// before\nnew Resource(name: null, variant, extension, loadType, offset, length, hashCode, compressedLength, compressedHashCode);\n// after\nif (string.IsNullOrEmpty(name)) throw new ArgumentException(\"Resource name required\");\nnew Resource(name, variant, extension, loadType, offset, length, hashCode, compressedLength, compressedHashCode);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(entry.Name)) { Log.Error(\"Pack resource entry missing name\"); return; }","typeGuard":"bool IsValidResourceName(string n) => !string.IsNullOrEmpty(n);","tryCatchPattern":"try { var r = new Resource(name, ...); } catch (GameFrameworkException ex) when (ex.Message == \"Name is invalid.\") { Log.Error(ex, \"Invalid pack resource entry\"); }","preventionTips":["Regenerate pack version lists via the official pipeline instead of hand-editing","Checksum-verify pack version files before parsing","Add parse-time sanity checks that reject entries without names"],"tags":["resource","version-list","constructor"],"backgroundTag":"invalid-constructor-argument","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}