{"record":{"id":"16d2c72e1231f0de","repo":"EllanJiang/GameFramework","slug":"entity-is-invalid","errorCode":null,"errorMessage":"Entity is invalid.","messagePattern":"Entity is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Entity/EntityManager.EntityInfo.cs","lineNumber":76,"sourceCode":"                set\n                {\n                    m_ParentEntity = value;\n                }\n            }\n\n            public int ChildEntityCount\n            {\n                get\n                {\n                    return m_ChildEntities.Count;\n                }\n            }\n\n            public static EntityInfo Create(IEntity entity)\n            {\n                if (entity == null)\n                {\n                    throw new GameFrameworkException(\"Entity is invalid.\");\n                }\n\n                EntityInfo entityInfo = ReferencePool.Acquire<EntityInfo>();\n                entityInfo.m_Entity = entity;\n                entityInfo.m_Status = EntityStatus.WillInit;\n                return entityInfo;\n            }\n\n            public void Clear()\n            {\n                m_Entity = null;\n                m_Status = EntityStatus.Unknown;\n                m_ParentEntity = null;\n                m_ChildEntities.Clear();\n            }\n\n            public IEntity GetChildEntity()\n            {","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Entity/EntityManager.EntityInfo.cs#L58-L94","documentation":"EntityInfo.Create is the ReferencePool-backed factory for the internal EntityInfo wrapper of an IEntity. It throws GameFrameworkException when the entity argument is null because an EntityInfo without an entity is meaningless and would corrupt entity management state. This is an internal API but reachable through custom entity code paths.","triggerScenarios":"Calling EntityInfo.Create(null) directly, or via EntityManager's show/attach flow when the IEntity created by an EntityHelper or entity logic was null.","commonSituations":"A custom EntityHelper.CreateInstance returning null (missing prefab/asset); entity logic object creation failing silently; misuse of internal APIs in derived entity managers.","solutions":["Ensure the IEntity passed to Create is a valid, non-null instance.","Check your EntityHelper's instance creation returns non-null (asset loaded correctly).","Null-check the entity before calling Create."],"exampleFix":"// before\nEntityInfo info = EntityInfo.Create(entity); // entity may be null\n// after\nif (entity != null)\n{\n    EntityInfo info = EntityInfo.Create(entity);\n}","handlingStrategy":"validation","validationCode":"if (entity == null) throw new ArgumentException(\"entity required\");\nvar info = EntityInfo.Create(entity);","typeGuard":"bool IsValidEntity(IEntity entity) => entity != null;","tryCatchPattern":"try { var info = EntityInfo.Create(entity); }\ncatch (GameFrameworkException ex) { Log.Error(\"EntityInfo.Create failed: {0}\", ex.Message); }","preventionTips":["Ensure EntityHelper instance creation never returns null","Validate entity before internal API calls","Check asset load success before creating entity logic"],"tags":["csharp","gameframework","null-argument","entity"],"backgroundTag":"null-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"}