{"record":{"id":"0db8eeee050af4ba","repo":"github/copilot-sdk","slug":"invalid-systemmessage-transform-payload-0db8ee","errorCode":null,"errorMessage":"invalid systemMessage.transform payload","messagePattern":"invalid systemMessage\\.transform payload","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/copilot/client.py","lineNumber":4994,"sourceCode":"        session_id = params.get(\"sessionId\")\n        if not session_id:\n            raise ValueError(\"invalid auto mode switch request payload\")\n\n        with self._sessions_lock:\n            session = self._sessions.get(session_id)\n        if not session:\n            raise ValueError(f\"unknown session {session_id}\")\n\n        response = await session._handle_auto_mode_switch_request(params)\n        return {\"response\": response}\n\n    async def _handle_system_message_transform(self, params: dict) -> dict:\n        \"\"\"Handle a systemMessage.transform request from the CLI server.\"\"\"\n        session_id = params.get(\"sessionId\")\n        sections = params.get(\"sections\")\n\n        if not session_id or not sections:\n            raise ValueError(\"invalid systemMessage.transform payload\")\n\n        with self._sessions_lock:\n            session = self._sessions.get(session_id)\n        if not session:\n            raise ValueError(f\"unknown session {session_id}\")\n\n        return await session._handle_system_message_transform(sections)\n","sourceCodeStart":4976,"sourceCodeEnd":5002,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/python/copilot/client.py#L4976-L5002","documentation":"Raised by the systemMessage.transform handler when the callback payload lacks either a truthy 'sessionId' or a non-empty 'sections' value. Both are required to route and apply the transform, so the payload is rejected with a ValueError.","triggerScenarios":"The CLI server sends a systemMessage.transform request where params['sessionId'] is missing/empty or params['sections'] is missing, None, or an empty collection.","commonSituations":"CLI/SDK schema mismatch after an upgrade, a CLI build that omits sections when there is nothing to transform, or a test harness sending a minimal params dict.","solutions":["Update the Copilot CLI so systemMessage.transform always carries sessionId and a non-empty sections list","Log the params dict to see which of the two required fields is missing","If emitting the request manually, supply both sessionId and sections (non-empty list)","Catch ValueError around dispatch and return an error response to the server"],"exampleFix":"// before\nawait client._handle_system_message_transform({\"sessionId\": sid})\n// after\nawait client._handle_system_message_transform({\"sessionId\": sid, \"sections\": [\"instructions\"]})","handlingStrategy":"validation","validationCode":"def valid_transform_params(p):\n    return isinstance(p, dict) and bool(p.get(\"sessionId\")) and bool(p.get(\"sections\"))","typeGuard":"def has_id_and_sections(p) -> bool:\n    return (\n        isinstance(p, dict)\n        and bool(p.get(\"sessionId\"))\n        and isinstance(p.get(\"sections\"), (list, dict))\n        and len(p[\"sections\"]) > 0\n    )","tryCatchPattern":"try:\n    await client._handle_system_message_transform(params)\nexcept ValueError as e:\n    logger.error(\"bad systemMessage.transform payload: %s | params=%r\", e, params)","preventionTips":["Always send both sessionId and a non-empty sections list","Add contract tests for the systemMessage.transform schema","Align CLI and SDK versions","Fail soft: return an error response instead of propagating the ValueError"],"tags":["validation","payload","system-message","rpc"],"backgroundTag":"empty-required-field","analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}