Add CreateSessionReKeyEntryTest for session-map re-key cleanup paths#233
Merged
Conversation
When the server returns a different sessionId and a subsequent step (e.g. updateSessionOptionsForMode) fails, the exceptionally blocks only removed the original sessionId from the sessions map, leaving the re-keyed entry behind as a stale/closed session. Fix: remove both the original and the active (possibly re-keyed) session ID in createSession/resumeSession exceptionally blocks, and unregister the session from the registry in updateSessionOptionsForMode before closing it. Addresses review comments on copilot-sdk PR #1473.
Contributor
There was a problem hiding this comment.
Pull request overview
Backports fixes from github/copilot-sdk#1473 to improve session lifecycle cleanup in the Java client and to enhance the standalone-vs-monorepo comparison script.
Changes:
- Remove re-keyed session entries from the
sessionsmap whencreateSession/resumeSessionfails after the server returns a different session ID. - Ensure failed
session.options.updateattempts also remove the session from the client’ssessionsmap. - Extend
scripts/compare-standalone-to-monorepo.shto comparescripts/codegen/java.tsbetween repos.
Show a summary per file
| File | Description |
|---|---|
| src/main/java/com/github/copilot/CopilotClient.java | Cleans up sessions map entries more robustly on failures, including re-keyed session IDs and failed post-create options patching. |
| scripts/compare-standalone-to-monorepo.sh | Adds explicit comparison of scripts/codegen/java.ts between standalone and monorepo Java directories. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 2
…aths Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
Copilot
AI
changed the title
Edburns/back sync from copilot sdk review
Add CreateSessionReKeyEntryTest for session-map re-key cleanup paths
May 27, 2026
edburns
added a commit
to github/copilot-sdk
that referenced
this pull request
May 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before the change?
After the change?
CreateSessionReKeyEntryTestwith three focused test cases:createSessionReKeyEntry_successfulReKey_removesOldKeyAndAddsNewKey— verifies the sessions map is correctly re-keyed when the server returns a different IDcreateSessionReKeyEntry_failureAfterReKey_removesBothKeys— verifies both the original and re-keyed entries are cleaned up whensession.options.updatefails after re-keyingcreateSessionReKeyEntry_noReKey_sameIdKept— baseline: verifies no re-key happens when server returns the same IDPull request checklist
mvn spotless:applyhas been run to format the codemvn clean verifypasses locallyDoes this introduce a breaking change?