fix: ignore body opencodeSessionId when session was reset
When session.opencodeSessionId is null (indicating the session was reset due to corruption or undo failure), ignore any opencodeSessionId sent in the request body. This prevents the client from reusing a corrupted session that was previously reset on the server.
This commit is contained in:
@@ -16906,7 +16906,15 @@ async function handleNewMessage(req, res, sessionId, userId) {
|
||||
if (body.originalMessageId) message.originalMessageId = body.originalMessageId;
|
||||
// Preserve opencodeSessionId for session continuity in retries/continuations
|
||||
// Also prioritize body.opencodeSessionId over session.opencodeSessionId for explicit continuation
|
||||
if (body.opencodeSessionId) {
|
||||
// CRITICAL: If session.opencodeSessionId is null (session was reset), ignore body.opencodeSessionId
|
||||
// to prevent reusing a corrupted session that was previously reset
|
||||
if (session.opencodeSessionId === null && body.opencodeSessionId) {
|
||||
log('Ignoring body opencodeSessionId because session was reset', {
|
||||
bodySessionId: body.opencodeSessionId,
|
||||
reason: 'Session was reset due to corruption/undo failure - forcing new session creation'
|
||||
});
|
||||
// Don't set message.opencodeSessionId - let ensureOpencodeSession create a new one
|
||||
} else if (body.opencodeSessionId) {
|
||||
message.opencodeSessionId = body.opencodeSessionId;
|
||||
log('Using explicit opencodeSessionId from request body', { opencodeSessionId: body.opencodeSessionId });
|
||||
} else if (session.opencodeSessionId) {
|
||||
|
||||
Reference in New Issue
Block a user