{"record":{"id":"c3b8f3b71bed4fdc","repo":"github/copilot-sdk","slug":"failed-to-unmarshal-send-response-w","errorCode":null,"errorMessage":"failed to unmarshal send response: %w","messagePattern":"failed to unmarshal send response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/session.go","lineNumber":452,"sourceCode":"\t\tPrompt:         options.Prompt,\n\t\tSource:         options.Source,\n\t\tDisplayPrompt:  options.DisplayPrompt,\n\t\tAttachments:    options.Attachments,\n\t\tMode:           options.Mode,\n\t\tAgentMode:      options.AgentMode,\n\t\tTraceparent:    traceparent,\n\t\tTracestate:     tracestate,\n\t\tRequestHeaders: options.RequestHeaders,\n\t}\n\n\tresult, err := s.client.Request(ctx, \"session.send\", req)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to send message: %w\", err)\n\t}\n\n\tvar response sessionSendResponse\n\tif err := json.Unmarshal(result, &response); err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to unmarshal send response: %w\", err)\n\t}\n\treturn response.MessageID, nil\n}\n\n// SendPrompt is a convenience wrapper for [Session.Send] that takes a plain\n// prompt string instead of a [MessageOptions] struct. Equivalent to:\n//\n//\tsession.Send(ctx, copilot.MessageOptions{Prompt: prompt})\nfunc (s *Session) SendPrompt(ctx context.Context, prompt string) (string, error) {\n\treturn s.Send(ctx, MessageOptions{Prompt: prompt})\n}\n\n// SendAndWait sends a message to this session and waits until the session becomes idle.\n//\n// This is a convenience method that combines [Session.Send] with waiting for\n// the session.idle event. Use this when you want to block until the assistant\n// has finished processing the message.\n//","sourceCodeStart":434,"sourceCodeEnd":470,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/go/session.go#L434-L470","documentation":"After a successful session.send request, Session.Send unmarshals the JSON result into sessionSendResponse to extract the message ID. This error indicates the server returned a response body that is not the expected JSON shape, so no message ID could be parsed.","triggerScenarios":"json.Unmarshal(result, &response) fails in Send — the RPC result is malformed JSON or lacks the fields sessionSendResponse expects (e.g. missing message_id).","commonSituations":"Client and server version mismatch where the server's send response schema changed; a proxy/gateway returning an error page instead of the RPC result; a server bug emitting an empty or HTML body.","solutions":["Log the raw `result` payload to see what the server actually returned.","Check for a client/server version mismatch and align versions.","Verify no proxy or gateway is intercepting and rewriting the RPC response.","Retry the send; if reproducible, report the malformed response to the server maintainers."],"exampleFix":"// before\n// server returns {\"id\":\"...\"} but client expects message_id — upgrade client\n// after\n// go get -u github.com/<org>/go@v<matching-server-version>","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"id, err := session.Send(ctx, msg, opts)\nif err != nil {\n    if strings.Contains(err.Error(), \"failed to unmarshal send response\") {\n        // log raw payload, check client/server version compatibility\n    }\n}","preventionTips":["Keep client and server versions matched","Ensure no proxies rewrite RPC responses","Log raw responses to catch schema drift early"],"tags":["json","rpc","response-parsing"],"backgroundTag":"json-unmarshal-failed","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"}