{"record":{"id":"88e00792107fcc3b","repo":"github/copilot-sdk","slug":"session-create-response-did-not-include-a-sessioni-88e007","errorCode":null,"errorMessage":"session.create response did not include a sessionId","messagePattern":"session\\.create response did not include a sessionId","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/client.go","lineNumber":1127,"sourceCode":"\n\t// For the server-assigned (cloud) path, register the session\n\t// synchronously from the read loop the instant the response arrives,\n\t// before the read loop dispatches the next message. Without this hook\n\t// the awaiter goroutine may not run until after the read loop has\n\t// dispatched the first session.event notification, which would be\n\t// silently dropped because the session id isn't yet in the lookup\n\t// table. Non-cloud sessions are already registered above.\n\tvar inlineCb func(raw json.RawMessage) error\n\tif session == nil {\n\t\tinlineCb = func(raw json.RawMessage) error {\n\t\t\tvar early struct {\n\t\t\t\tSessionID string `json:\"sessionId\"`\n\t\t\t}\n\t\t\tif err := json.Unmarshal(raw, &early); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to parse sessionId from response: %w\", err)\n\t\t\t}\n\t\t\tif early.SessionID == \"\" {\n\t\t\t\treturn fmt.Errorf(\"session.create response did not include a sessionId\")\n\t\t\t}\n\t\t\ts, err := initializeSession(early.SessionID)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tsession = s\n\t\t\tregisteredSessionID = early.SessionID\n\t\t\treturn nil\n\t\t}\n\t}\n\n\tresult, err := c.client.RequestWithInlineResponse(ctx, \"session.create\", req, inlineCb)\n\tif err != nil {\n\t\tif registeredSessionID != \"\" {\n\t\t\tunregisterSession(registeredSessionID, session)\n\t\t}\n\t\treturn nil, fmt.Errorf(\"failed to create session: %w\", err)\n\t}","sourceCodeStart":1109,"sourceCodeEnd":1145,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/go/client.go#L1109-L1145","documentation":"In the inline (first) session-creation path, the client unmarshals the session.create response into a struct with a SessionID field. If the JSON parses but the sessionId field is empty or absent, this error is thrown. The server acknowledged the request but did not return an identifier the client needs to register the session.","triggerScenarios":"CreateSession (inline path, session == nil) where the session.create response is valid JSON but lacks a non-empty \"sessionId\" field — e.g. server returns {} or {\"sessionId\": \"\"}.","commonSituations":"Running against an older server that names the field differently (e.g. \"id\"); mock/test servers returning incomplete payloads; server-side errors swallowed into an empty 200 response.","solutions":["Check the server response actually contains a sessionId field (log/capture the raw payload)","Upgrade the server to a version compatible with this SDK's session.create contract","If using a mock server, add sessionId to its canned response","Check for server-side partial-failure handling that returns 200 with an empty body"],"exampleFix":"// mock server before\n{\"ok\": true}\n// after\n{\"ok\": true, \"sessionId\": \"sess_123\"}","handlingStrategy":"validation","validationCode":"var probe struct{ SessionID string `json:\"sessionId\"` }\nif err := json.Unmarshal(raw, &probe); err != nil || probe.SessionID == \"\" {\n    return errors.New(\"server response lacks sessionId\")\n}","typeGuard":null,"tryCatchPattern":"s, err := client.CreateSession(ctx, opts)\nif err != nil && strings.Contains(err.Error(), \"did not include a sessionId\") {\n    log.Printf(\"session.create payload: %s\", rawBody)\n    return upgradeServerError(err)\n}","preventionTips":["Keep server and SDK versions aligned","Add sessionId to mock/stub responses in tests","Assert the response contract in integration tests"],"tags":["rpc","session","missing-field","response-contract"],"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"}