{"record":{"id":"16a2bb6f66b63f96","repo":"github/copilot-sdk","slug":"invalid-systemmessage-transform-payload","errorCode":null,"errorMessage":"Invalid systemMessage.transform payload","messagePattern":"Invalid systemMessage\\.transform payload","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nodejs/src/client.ts","lineNumber":3262,"sourceCode":"        if (!session) {\n            throw new Error(`Session not found: ${params.sessionId}`);\n        }\n\n        const output = await session._handleHooksInvoke(params.hookType, params.input);\n        return { output };\n    }\n\n    private async handleSystemMessageTransform(params: {\n        sessionId: string;\n        sections: Record<string, { content: string }>;\n    }): Promise<{ sections: Record<string, { content: string }> }> {\n        if (\n            !params ||\n            typeof params.sessionId !== \"string\" ||\n            !params.sections ||\n            typeof params.sections !== \"object\"\n        ) {\n            throw new Error(\"Invalid systemMessage.transform payload\");\n        }\n\n        const session = this.sessions.get(params.sessionId);\n        if (!session) {\n            throw new Error(`Session not found: ${params.sessionId}`);\n        }\n\n        return await session._handleSystemMessageTransform(params.sections);\n    }\n}\n","sourceCodeStart":3244,"sourceCodeEnd":3273,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/nodejs/src/client.ts#L3244-L3273","documentation":"The systemMessage.transform handler requires params with a string sessionId and a non-null object sections; otherwise it throws. sections is the map of system-message sections to transform, so the library rejects anything falsy or non-object before session dispatch.","triggerScenarios":"Calling the systemMessage.transform method with params null, sessionId not a string, sections undefined/null, or sections a non-object (string, number, array edge cases still pass Array check only for object typeof).","commonSituations":"Transform callback returning undefined and its result piped directly as params; sections built by spreading an optional config ({} lost); passing a single section string instead of the sections map.","solutions":["Always pass sections as an object/map of section names to content, defaulting to {} when empty.","Guard the transform output before forwarding: only call the API when the result is a non-null object.","Fix field naming so the sections map is not nested (params.sections.sections).","Coerce primitive section values into an object wrapper."],"exampleFix":"// before\nawait client.handleSystemMessageTransform({ sessionId, sections: transform(input) });\n// after\nconst sections = transform(input);\nawait client.handleSystemMessageTransform({\n  sessionId,\n  sections: sections && typeof sections === \"object\" ? sections : {}\n});","handlingStrategy":"validation","validationCode":"if (!params || typeof params.sessionId !== \"string\" || !params.sections || typeof params.sections !== \"object\") {\n  throw new TypeError(\"systemMessage.transform requires sessionId and sections object\");\n}","typeGuard":"function isSystemMessageTransformParams(p): p is { sessionId: string; sections: Record<string, unknown> } {\n  return typeof p === \"object\" && p !== null &&\n    typeof (p as any).sessionId === \"string\" &&\n    typeof (p as any).sections === \"object\" && (p as any).sections !== null;\n}","tryCatchPattern":"try {\n  await client.handleSystemMessageTransform(params);\n} catch (e) {\n  if (e instanceof Error && e.message === \"Invalid systemMessage.transform payload\") {\n    // default sections to {} and retry once\n  }\n}","preventionTips":["Default transform outputs to {} instead of letting undefined propagate.","Type transform callbacks to always return a sections object.","Test transform functions with empty and partial inputs."],"tags":["validation","payload","system-message","typescript"],"backgroundTag":"schema-validation-failed","analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}