{"record":{"id":"1fdf3713572cb626","repo":"EllanJiang/GameFramework","slug":"ui-form-is-invalid-uimanager-uigroup","errorCode":null,"errorMessage":"UI form is invalid.","messagePattern":"UI form is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/UI/UIManager.UIGroup.cs","lineNumber":502,"sourceCode":"                    {\n                        results.Add(uiFormInfo.UIForm);\n                    }\n                }\n            }\n\n            internal void InternalGetAllUIForms(List<IUIForm> results)\n            {\n                foreach (UIFormInfo uiFormInfo in m_UIFormInfos)\n                {\n                    results.Add(uiFormInfo.UIForm);\n                }\n            }\n\n            private UIFormInfo GetUIFormInfo(IUIForm uiForm)\n            {\n                if (uiForm == null)\n                {\n                    throw new GameFrameworkException(\"UI form is invalid.\");\n                }\n\n                foreach (UIFormInfo uiFormInfo in m_UIFormInfos)\n                {\n                    if (uiFormInfo.UIForm == uiForm)\n                    {\n                        return uiFormInfo;\n                    }\n                }\n\n                return null;\n            }\n        }\n    }\n}\n","sourceCodeStart":484,"sourceCodeEnd":518,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/UI/UIManager.UIGroup.cs#L484-L518","documentation":"GetUIFormInfo is the private lookup used by RemoveUIForm/RefocusUIForm. It throws GameFrameworkException('UI form is invalid.') when the uiForm parameter itself is null, before any list search, because a null form can never match a tracked instance.","triggerScenarios":"Calling RemoveUIForm(null) or RefocusUIForm(null) — i.e. CloseUIForm or RefocusUIForm propagated a null form reference.","commonSituations":"CloseUIForm fed by a dictionary lookup that missed; a nullable form field never assigned; async open flows where the form reference is captured before it is available.","solutions":["Null-check the IUIForm reference before CloseUIForm/RefocusUIForm","Fix the lookup/assignment that produced the null reference","Wait for the async OpenUIForm callback before closing or refocusing the form"],"exampleFix":"// before\nuiGroup.CloseUIForm(m_Form); // m_Form may be null\n// after\nif (m_Form != null)\n{\n    uiGroup.CloseUIForm(m_Form);\n    m_Form = null;\n}","handlingStrategy":"validation","validationCode":"if (uiForm == null) return;","typeGuard":"bool IsValidForm(IUIForm form) => form != null;","tryCatchPattern":"try { uiGroup.CloseUIForm(uiForm); } catch (GameFrameworkException ex) when (ex.Message == \"UI form is invalid.\") { Log.Warn(\"Attempted to close a null UI form\"); }","preventionTips":["Null-check form references from lookups before UI API calls","Set references to null explicitly after close and check before reuse","Await the OpenUIForm callback before using the form reference"],"tags":["unity","gameframework","ui","null-argument"],"backgroundTag":"null-argument","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}