{"record":{"id":"5735b5a2eaedb753","repo":"github/copilot-sdk","slug":"failed-to-unmarshal-get-events-response-w","errorCode":null,"errorMessage":"failed to unmarshal get events response: %w","messagePattern":"failed to unmarshal get events response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/session.go","lineNumber":1808,"sourceCode":"//\tif err != nil {\n//\t    log.Printf(\"Failed to get events: %v\", err)\n//\t    return\n//\t}\n//\tfor _, event := range events {\n//\t    if d, ok := event.Data.(*copilot.AssistantMessageData); ok {\n//\t        fmt.Println(\"Assistant:\", d.Content)\n//\t    }\n//\t}\nfunc (s *Session) GetEvents(ctx context.Context) ([]SessionEvent, error) {\n\n\tresult, err := s.client.Request(ctx, \"session.getMessages\", sessionGetMessagesRequest{SessionID: s.SessionID})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get events: %w\", err)\n\t}\n\n\tvar response sessionGetMessagesResponse\n\tif err := json.Unmarshal(result, &response); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to unmarshal get events response: %w\", err)\n\t}\n\treturn response.Events, nil\n}\n\n// Disconnect closes this session and releases all in-memory resources (event\n// handlers, tool handlers, permission handlers).\n//\n// The caller should ensure the session is idle (e.g., [Session.SendAndWait] has\n// returned) before disconnecting. If the session is not idle, in-flight event\n// handlers or tool handlers may observe failures.\n//\n// Session state on disk (conversation history, planning state, artifacts) is\n// preserved, so the conversation can be resumed later by calling\n// [Client.ResumeSession] with the session ID. To permanently remove all\n// session data including files on disk, use [Client.DeleteSession] instead.\n//\n// After calling this method, the session object can no longer be used.\n//","sourceCodeStart":1790,"sourceCodeEnd":1826,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/go/session.go#L1790-L1826","documentation":"After the `session.getMessages` RPC succeeds, GetEvents unmarshals the result payload into sessionGetMessagesResponse. This error means the response JSON could not be decoded into that struct — the runtime returned data that does not match the SDK's expected event-response shape.","triggerScenarios":"Calling Session.GetEvents when the runtime's reply for `session.getMessages` has fields with unexpected types or an incompatible schema (json.Unmarshal into sessionGetMessagesResponse fails).","commonSituations":"SDK version older/newer than the running runtime so the messages payload shape differs; a proxy or patched runtime returning non-standard JSON; corrupted payload over the transport.","solutions":["Upgrade the Go SDK and the runtime/CLI to matching versions","Log the raw `result` payload to inspect the actual response shape","Check for a proxy/interceptor altering the response","Report the mismatch if the runtime is current and shapes still differ"],"exampleFix":"// before\nevents, err := session.GetEvents(ctx)\n// after\nevents, err := session.GetEvents(ctx)\nif err != nil && strings.Contains(err.Error(), \"unmarshal get events\") {\n    log.Fatalf(\"runtime/SDK version mismatch on getMessages payload: %v\", err)\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"events, err := session.GetEvents(ctx)\nif err != nil && strings.Contains(err.Error(), \"unmarshal\") {\n    log.Printf(\"response shape mismatch (SDK/runtime version skew?): %v\", err)\n}","preventionTips":["Keep the Go SDK and runtime/CLI versions aligned","Pin versions in CI so payloads and structs can't drift apart","Dump raw RPC payloads when debugging decode failures"],"tags":["go","json","unmarshal","rpc"],"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"}