{"record":{"id":"cf1d99daa2de5319","repo":"Unity-Technologies/ml-agents","slug":"you-cannot-set-the-width-height-of-the-screen-reso","errorCode":null,"errorMessage":"You cannot set the width/height of the screen resolution without also setting the height/width","messagePattern":"You cannot set the width/height of the screen resolution without also setting the height/width","errorType":"exception","errorClass":"UnitySideChannelException","httpStatus":null,"severity":"error","filePath":"ml-agents-envs/mlagents_envs/side_channel/engine_configuration_channel.py","lineNumber":86,"sourceCode":"        \"\"\"\n        Sets the engine configuration. Takes as input the configurations of the\n        engine.\n        :param width: Defines the width of the display. (Must be set alongside height)\n        :param height: Defines the height of the display. (Must be set alongside width)\n        :param quality_level: Defines the quality level of the simulation.\n        :param time_scale: Defines the multiplier for the deltatime in the\n        simulation. If set to a higher value, time will pass faster in the\n        simulation but the physics might break.\n        :param target_frame_rate: Instructs simulation to try to render at a\n        specified frame rate.\n        :param capture_frame_rate: Instructs the simulation to consider time between\n        updates to always be constant, regardless of the actual frame rate.\n        \"\"\"\n\n        if (width is None and height is not None) or (\n            width is not None and height is None\n        ):\n            raise UnitySideChannelException(\n                \"You cannot set the width/height of the screen resolution without also setting the height/width\"\n            )\n\n        if width is not None and height is not None:\n            screen_msg = OutgoingMessage()\n            screen_msg.write_int32(self.ConfigurationType.SCREEN_RESOLUTION)\n            screen_msg.write_int32(width)\n            screen_msg.write_int32(height)\n            super().queue_message_to_send(screen_msg)\n\n        if quality_level is not None:\n            quality_level_msg = OutgoingMessage()\n            quality_level_msg.write_int32(self.ConfigurationType.QUALITY_LEVEL)\n            quality_level_msg.write_int32(quality_level)\n            super().queue_message_to_send(quality_level_msg)\n\n        if time_scale is not None:\n            time_scale_msg = OutgoingMessage()","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/Unity-Technologies/ml-agents/blob/3ecb446f75d1e7400eb404c562dc005d3164cffc/ml-agents-envs/mlagents_envs/side_channel/engine_configuration_channel.py#L68-L104","documentation":"set_configuration_parameters requires width and height to be set together when configuring screen resolution. Passing exactly one of them is ambiguous, so it raises UnitySideChannelException before sending any message.","triggerScenarios":"Calling engine_config_channel.set_configuration_parameters(width=1280) or (height=720) without the other, then env.step().","commonSituations":"Scripted config where one resolution value comes from an env var/CLI arg that is missing; copy-paste edits dropping one parameter.","solutions":["Pass both width and height (or neither): set_configuration_parameters(width=1280, height=720).","Default missing values explicitly, e.g. width=int(os.environ.get('WIDTH', 1280)).","Use the convenience set_configuration(...) which groups parameters, still supplying both dimensions.","Validate width/height are both None or both ints before calling."],"exampleFix":"// before\nengine_config_channel.set_configuration_parameters(width=1280)\n// after\nengine_config_channel.set_configuration_parameters(width=1280, height=720)","handlingStrategy":"validation","validationCode":"def valid_resolution(width, height):\n    return (width is None and height is None) or (isinstance(width, int) and isinstance(height, int) and width > 0 and height > 0)\nassert valid_resolution(width, height), \"width and height must both be set or both None\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass width and height together","Load both values from config with explicit defaults","Add a pre-call assertion or validation helper","Use set_configuration() to set grouped parameters consistently"],"tags":["configuration","validation","arguments"],"backgroundTag":"invalid-parameter-combination","analyzedSha":"3ecb446f75d1e7400eb404c562dc005d3164cffc","analyzedAt":"2026-09-02T16:33:12.832Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}