{"record":{"id":"8211dc613efc4b94","repo":"Unity-Technologies/UnityCsReference","slug":"entityid-was-not-found","errorCode":null,"errorMessage":"EntityId was not found: ","messagePattern":"EntityId was not found: ","errorType":"exception","errorClass":"KeyNotFoundException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/ProjectBrowser/ProjectBrowserColumnOne.cs","lineNumber":624,"sourceCode":"                {\n                    CacheMapping(id, pair.entityId);\n                    return pair.entityId;\n                }\n            }\n\n            // Allocate new EntityId\n            var newEntityId = EntityId.AllocateEntityId();\n            m_AllocatedEntityIds.Add(new IdPair(id, newEntityId));\n            CacheMapping(id, newEntityId);\n            return newEntityId;\n        }\n\n        public int GetIdFor(EntityId entityId)\n        {\n            if (TryGetIdFor(entityId, out int id))\n                return id;\n\n            throw new KeyNotFoundException(\"EntityId was not found: \" + entityId);\n        }\n\n        public bool TryGetIdFor(EntityId entityId, out int id)\n        {\n            if (m_LookupId.TryGetValue(entityId, out int intId))\n            {\n                id = intId;\n                return true;\n            }\n\n            // Fallback to list traversal (should only happen once per id, at startup and after domain reloading)\n            foreach (var pair in m_AllocatedEntityIds)\n            {\n                if (pair.entityId == entityId)\n                {\n                    CacheMapping(pair.id, entityId);\n                    id = pair.id;\n                    return true;","sourceCodeStart":606,"sourceCodeEnd":642,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/ProjectBrowser/ProjectBrowserColumnOne.cs#L606-L642","documentation":"ProjectBrowserColumnOne.GetIdFor throws a KeyNotFoundException when the requested EntityId has no mapping in the internal lookup. This is an internal editor method for the Project Browser's virtualized list view that maps EntityIds to internal integer IDs for rendering.","triggerScenarios":"Calling GetIdFor with an EntityId that was never allocated through AllocateEntityId (internal) or was allocated in a previous session and lost after a domain reload.","commonSituations":"This is an internal Unity editor API not intended for direct use. Errors here typically come from bugs in Unity's own Project Browser code after a domain reload or asset import where EntityId mappings become stale. Custom editor extensions that manipulate project browser internals may also trigger it.","solutions":["This is an internal API; restart the editor or force a Project Browser repaint/reload if hit.","Use TryGetIdFor (the non-throwing variant) if you have internal access and need to guard.","Avoid manipulating EntityId mappings from custom editor code; they are managed by the Project Browser internally."],"exampleFix":"// before\nint id = browser.GetIdFor(entityId);\n// after (if internal access available)\nif (browser.TryGetIdFor(entityId, out int id))\n{ /* use id */ }\nelse\n    Debug.LogWarning(\"EntityId not found, likely stale after domain reload\");","handlingStrategy":"validation","validationCode":"// Internal API — use TryGetIdFor instead of GetIdFor\nif (browser.TryGetIdFor(entityId, out int id))\n{ /* use id */ }\nelse\n    Debug.LogWarning(\"EntityId not mapped\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["This is an internal Unity editor API; do not call it directly from custom code","Use the Try-pattern variant (TryGetIdFor) instead of the throwing GetIdFor","Restart the editor if Project Browser state becomes corrupted after domain reload"],"tags":["unity","editor","project-browser","internal-api","key-not-found"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}