{"record":{"id":"bd294b76b3ed2ffc","repo":"CoplayDev/unity-mcp","slug":"pluginhub-session-missing-required-project-or-h","errorCode":null,"errorMessage":"PluginHub session missing required 'project' or 'hash' fields.","messagePattern":"PluginHub session missing required 'project' or 'hash' fields\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"Server/src/services/resources/unity_instances.py","lineNumber":54,"sourceCode":"    await ctx.info(\"Listing Unity instances\")\n\n    try:\n        transport = (config.transport_mode or \"stdio\").lower()\n        if transport == \"http\":\n            # HTTP/WebSocket transport: query PluginHub\n            # In remote-hosted mode, filter sessions by user_id\n            user_id = (await ctx.get_state(\n                \"user_id\")) if config.http_remote_hosted else None\n            sessions_data = await PluginHub.get_sessions(user_id=user_id)\n            sessions = sessions_data.sessions\n\n            instances = []\n            for session_id, session_info in sessions.items():\n                project = session_info.project\n                project_hash = session_info.hash\n\n                if not project or not project_hash:\n                    raise ValueError(\n                        \"PluginHub session missing required 'project' or 'hash' fields.\"\n                    )\n\n                instances.append({\n                    \"id\": f\"{project}@{project_hash}\",\n                    \"name\": project,\n                    \"hash\": project_hash,\n                    \"unity_version\": session_info.unity_version,\n                    \"connected_at\": session_info.connected_at,\n                    \"session_id\": session_id,\n                })\n\n            # Check for duplicate project names\n            name_counts = {}\n            for inst in instances:\n                name_counts[inst[\"name\"]] = name_counts.get(\n                    inst[\"name\"], 0) + 1\n","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/CoplayDev/unity-mcp/blob/c21bf496bca87d54e75bad048563c3adb1782081/Server/src/services/resources/unity_instances.py#L36-L72","documentation":"Raised by the unity_instances MCP resource when iterating over WebSocket sessions from PluginHub and a SessionDetails entry has a falsy project or hash field. SessionDetails (transport/models.py:60) declares project and hash as required str fields, so Pydantic should enforce non-empty strings at parse time — but the guard also catches empty-string values ('' is falsy) that pass Pydantic's str validation. This indicates a Unity plugin registered a session with incomplete handshake data.","triggerScenarios":"A Unity Editor connected via WebSocket and sent a session registration message with empty project name or empty hash; a race condition where the session was registered mid-handshake before the project path was resolved; a corrupt or partial PluginHub session store after a server crash; an older Unity plugin version that does not send the hash field.","commonSituations":"Unity plugin version mismatch (older plugin omits hash); a Unity project whose path could not be hashed (permissions, unusual path); PluginHub state deserialized from a stale/corrupt store after an unclean shutdown; a transient registration race during rapid connect/disconnect.","solutions":["Update the MCP for Unity package in the Unity Editor to match the server version — older plugins may not send the hash field.","Restart the Unity Editor so it re-registers its session with a complete handshake.","If persistent, clear the PluginHub session store (check for a sessions cache/state file) and reconnect.","Report the session_id from server logs to identify which Unity instance sent incomplete data."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# Validate session data before building instances list\nfor session_id, session_info in sessions.items():\n    project = getattr(session_info, \"project\", None)\n    project_hash = getattr(session_info, \"hash\", None)\n    if not project or not project_hash:\n        # Skip incomplete sessions instead of raising, or log for investigation\n        logger.warning(\"Skipping incomplete session %s: project=%r hash=%r\", session_id, project, project_hash)\n        continue","typeGuard":"from transport.models import SessionDetails\n\ndef is_complete_session(s: SessionDetails) -> bool:\n    return bool(getattr(s, \"project\", None)) and bool(getattr(s, \"hash\", None))","tryCatchPattern":null,"preventionTips":["Keep the Unity plugin version aligned with the server so sessions always include project and hash.","Restart the Unity Editor if sessions appear incomplete after a crash or version change.","In multi-user deployments, monitor for incomplete session registrations in server logs."],"tags":["data-integrity","pluginhub","session","validation","version-mismatch"],"backgroundTag":null,"analyzedSha":"c21bf496bca87d54e75bad048563c3adb1782081","analyzedAt":"2026-08-13T17:36:56.095Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}