{"record":{"id":"895f2b17a357cf2e","repo":"EllanJiang/GameFramework","slug":"ui-form-asset-name-is-invalid","errorCode":null,"errorMessage":"UI form asset name is invalid.","messagePattern":"UI form asset name is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/UI/UIManager.UIGroup.cs","lineNumber":188,"sourceCode":"                    if (uiFormInfo.UIForm.SerialId == serialId)\n                    {\n                        return true;\n                    }\n                }\n\n                return false;\n            }\n\n            /// <summary>\n            /// 界面组中是否存在界面。\n            /// </summary>\n            /// <param name=\"uiFormAssetName\">界面资源名称。</param>\n            /// <returns>界面组中是否存在界面。</returns>\n            public bool HasUIForm(string uiFormAssetName)\n            {\n                if (string.IsNullOrEmpty(uiFormAssetName))\n                {\n                    throw new GameFrameworkException(\"UI form asset name is invalid.\");\n                }\n\n                foreach (UIFormInfo uiFormInfo in m_UIFormInfos)\n                {\n                    if (uiFormInfo.UIForm.UIFormAssetName == uiFormAssetName)\n                    {\n                        return true;\n                    }\n                }\n\n                return false;\n            }\n\n            /// <summary>\n            /// 从界面组中获取界面。\n            /// </summary>\n            /// <param name=\"serialId\">界面序列编号。</param>\n            /// <returns>要获取的界面。</returns>","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/UI/UIManager.UIGroup.cs#L170-L206","documentation":"UIGroup.HasUIForm validates its lookup key and throws when uiFormAssetName is null or empty. The method compares each form's asset name against this key, so a blank key cannot match and would only hide caller bugs.","triggerScenarios":"Calling UIGroup.HasUIForm (often via UIComponent.HasUIForm) with a null or empty asset-name string.","commonSituations":"Form asset name stored in a variable loaded from config that was empty; string concatenation produced an empty path; calling a validity check before actually choosing the asset to test.","solutions":["Pass the full, non-empty asset name (e.g. \"Assets/Game/UI/DialogForm.prefab\") to HasUIForm.","Check where the name comes from — fix empty config fields or unassigned fields before querying.","Trim/validate the name at the call site."],"exampleFix":"// before\nbool exists = UIComponent.HasUIForm(formAssetName); // empty\n// after\nbool exists = !string.IsNullOrEmpty(formAssetName) && UIComponent.HasUIForm(formAssetName);","handlingStrategy":"validation","validationCode":"if (!string.IsNullOrEmpty(uiFormAssetName))\n{\n    bool exists = UIComponent.HasUIForm(uiFormAssetName);\n}","typeGuard":"bool HasName(string s) => !string.IsNullOrEmpty(s);","tryCatchPattern":"try { exists = UIComponent.HasUIForm(name); }\ncatch (GameFrameworkException ex) { Log.Error(ex, \"HasUIForm called with empty name\"); }","preventionTips":["Guard dynamic asset-name construction before use","Keep asset names in a central table with startup validation","Return early when the name source is empty instead of querying"],"tags":["unity","gameframework","ui","empty-string"],"backgroundTag":"empty-required-field","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"}