{"record":{"id":"7c43d35666b30aee","repo":"Unity-Technologies/ml-agents","slug":"there-cannot-be-two-side-channels-with-the-same-ch","errorCode":null,"errorMessage":"There cannot be two side channels with the same channel id {_sc.channel_id}.","messagePattern":"There cannot be two side channels with the same channel id (.+?)\\.","errorType":"exception","errorClass":"UnityEnvironmentException","httpStatus":null,"severity":"error","filePath":"ml-agents-envs/mlagents_envs/side_channel/side_channel_manager.py","lineNumber":76,"sourceCode":"                result += channel_id.bytes_le\n                result += struct.pack(\"<i\", len(message))\n                result += message\n            channel.message_queue = []\n        return result\n\n    @staticmethod\n    def _get_side_channels_dict(\n        side_channels: Optional[List[SideChannel]],\n    ) -> Dict[uuid.UUID, SideChannel]:\n        \"\"\"\n        Converts a list of side channels into a dictionary of channel_id to SideChannel\n        :param side_channels: The list of side channels.\n        \"\"\"\n        side_channels_dict: Dict[uuid.UUID, SideChannel] = {}\n        if side_channels is not None:\n            for _sc in side_channels:\n                if _sc.channel_id in side_channels_dict:\n                    raise UnityEnvironmentException(\n                        f\"There cannot be two side channels with \"\n                        f\"the same channel id {_sc.channel_id}.\"\n                    )\n                side_channels_dict[_sc.channel_id] = _sc\n        return side_channels_dict\n","sourceCodeStart":58,"sourceCodeEnd":82,"githubUrl":"https://github.com/Unity-Technologies/ml-agents/blob/3ecb446f75d1e7400eb404c562dc005d3164cffc/ml-agents-envs/mlagents_envs/side_channel/side_channel_manager.py#L58-L82","documentation":"SideChannelManager registers side channels in a dict keyed by channel_id; duplicate UUIDs would silently overwrite each other, so during construction (_get_side_channels_dict, called from __init__) a UnityEnvironmentException is raised if two channels share an id.","triggerScenarios":"UnityEnvironment(..., side_channels=[a, b]) or SideChannelManager(side_channels=[...]) where two SideChannel instances return the same channel_id (e.g. two EngineConfigurationChannel instances, or a custom channel reusing a built-in UUID).","commonSituations":"Adding the same side-channel object twice to the list; instantiating two channels of the same class; custom channel accidentally copying a built-in channel id.","solutions":["Remove duplicate instances from the side_channels list before constructing UnityEnvironment.","Reuse one channel instance everywhere instead of creating a second of the same class.","Change the custom channel's channel_id to a fresh uuid.uuid4() if it collides with a built-in.","Deduplicate defensively: pass list({c.channel_id: c for c in channels}.values()) into the env."],"exampleFix":"// before\nchannels = [EngineConfigurationChannel(), EngineConfigurationChannel()]\nenv = UnityEnvironment(file_name=env_path, side_channels=channels)\n// after\nengine_channel = EngineConfigurationChannel()\nenv = UnityEnvironment(file_name=env_path, side_channels=[engine_channel])","handlingStrategy":"validation","validationCode":"ids = [c.channel_id for c in side_channels]\nassert len(ids) == len(set(ids)), f\"duplicate side channel ids: {ids}\"","typeGuard":"def no_duplicate_channels(channels):\n    ids = [c.channel_id for c in channels]\n    return len(ids) == len(set(ids))","tryCatchPattern":"from mlagents_envs.exception import UnityEnvironmentException\ntry:\n    env = UnityEnvironment(file_name=path, side_channels=channels)\nexcept UnityEnvironmentException as e:\n    print(\"Deduplicate your side_channels list:\", e)","preventionTips":["Deduplicate side_channels before constructing UnityEnvironment","Create one channel instance and reuse it","Give custom channels unique uuid4 ids","Never append the same list twice"],"tags":["configuration","side-channel","duplicate-id"],"backgroundTag":"duplicate-side-channel-id","analyzedSha":"3ecb446f75d1e7400eb404c562dc005d3164cffc","analyzedAt":"2026-09-02T16:33:12.832Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}