{"record":{"id":"1c81de539a51ab18","repo":"Unity-Technologies/UnityCsReference","slug":"guid","errorCode":null,"errorMessage":"guid","messagePattern":"guid","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/Prefabs/PrefabFamilyPopup.cs","lineNumber":634,"sourceCode":"        }\n\n        public static PrefabAssetInfo GetState(string guid)\n        {\n            var id = GetPrefabAssetIdentifier(guid);\n            var cachedPrefabAssetInfo = s_StateCache.GetState(id);\n            if (cachedPrefabAssetInfo == null)\n                return null; // not cached yet\n\n            var currentPrefabSourceFileHash = AssetDatabase.GetSourceAssetFileHash(guid);\n            if (currentPrefabSourceFileHash != cachedPrefabAssetInfo.prefabFileHash)\n                return null; // cache is out of sync\n\n            return cachedPrefabAssetInfo;\n        }\n        public static Hash128 GetPrefabAssetIdentifier(string guid)\n        {\n            if (string.IsNullOrEmpty(guid))\n                throw new ArgumentNullException(nameof(guid));\n\n            return Hash128.Compute(guid);\n        }\n    }\n\n    class OverridesCounterForPrefabAssets\n    {\n        GameObject[] m_PrefabAssetRoots;\n        List<int> m_OverridesCount;\n        int m_CurrentAssetIndex;\n        int m_CurrentStep;\n        bool m_ChangedCount;\n\n        bool m_Debug = false;\n\n        public OverridesCounterForPrefabAssets(GameObject[] prefabInstanceRoots)\n        {\n            m_PrefabAssetRoots = prefabInstanceRoots;","sourceCodeStart":616,"sourceCodeEnd":652,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/Prefabs/PrefabFamilyPopup.cs#L616-L652","documentation":"PrefabFamilyPopup.GetPrefabAssetIdentifier computes a Hash128 from a GUID string to use as a cache key for prefab asset info. The method throws ArgumentNullException when the guid parameter is null or empty, since Hash128.Compute on an empty string would produce a meaningless key. This is a precondition guard on an internal static utility method.","triggerScenarios":"Calling PrefabFamilyPopup.GetPrefabAssetIdentifier(null) or GetPrefabAssetIdentifier(\"\") directly. Passing a GUID obtained from AssetDatabase.AssetPathToGUID on a path that returned an empty string (e.g., for a scene object that is not an asset).","commonSituations":"Code that derives a GUID from an asset path but doesn't check whether the path resolved to a valid asset. Scene objects passed to asset-guid lookup functions. Programmatically constructed objects that have no asset backing.","solutions":["Check string.IsNullOrEmpty(guid) before calling GetPrefabAssetIdentifier","Verify the source GameObject is an asset (PrefabUtility.IsPartOfPrefabAsset) before extracting its GUID","Use AssetDatabase.TryGetAssetPathFromGUID or validate the GUID format before passing it"],"exampleFix":"// before\nHash128 id = PrefabFamilyPopup.GetPrefabAssetIdentifier(guid);\n\n// after\nif (!string.IsNullOrEmpty(guid))\n    Hash128 id = PrefabFamilyPopup.GetPrefabAssetIdentifier(guid);\nelse\n    return; // or handle the missing-asset case","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(guid))\n    throw new InvalidOperationException(\"GUID is null or empty — cannot compute prefab asset identifier.\");\n// Safe to call GetPrefabAssetIdentifier(guid)","typeGuard":"static bool IsValidGuid(string guid) => !string.IsNullOrEmpty(guid) && guid.Length == 32;","tryCatchPattern":"try { Hash128 id = PrefabFamilyPopup.GetPrefabAssetIdentifier(guid); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"guid\")\n{ Debug.LogError(\"GUID is null or empty.\"); }","preventionTips":["Always null-check and empty-check GUID strings before passing to identifier methods","Validate the source asset path resolved to a non-empty GUID via AssetDatabase.AssetPathToGUID","Use a helper method to guard all GUID-dependent calls"],"tags":["unity","editor-scripting","prefab","validation","guid","argumentnullexception"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}