8000 Guard nil SessionID when logging EventResumed in gateway listener by Copilot · Pull Request #632 · disgoorg/disgo · GitHub
[go: up one dir, main page]

Skip to content

Guard nil SessionID when logging EventResumed in gateway listener - #632

Closed
topi314 with Copilot wants to merge 3 commits into
masterfrom
copilot/fix-nil-pointer-dereference
Closed

topi314 with Copilot wants to merge 3 commits into
masterfrom
copilot/fix-nil-pointer-dereference

Conversation

Copilot AI commented Oct 23, 2026 •
Copy link
Copy Markdown

gatewayImpl.listen dereferences g.config.SessionID when logging a RESUMED event. After an Invalid Session (canResume == false) clears resume state, a late RESUMED can arrive while SessionID is nil. The dereference then panics and crashes the host process.

  • Fix (gateway/gateway.go): the EventResumed branch now logs an empty session_id when SessionID is nil. The status transition to StatusReady and the ready(nil) call are unchanged.
sessionID := ""
if g.config.SessionID != nil {
    sessionID = *g.config.SessionID
}
g.config.Logger.Debug("successfully resumed", slog.String("session_id", sessionID))

Not addressed

  • The issue also suggests a recover() barrier in listen(). I left it out because it would hide other bugs. Say if you want it added.
  • resume() dereferences SessionID and LastSequenceReceived without a nil check. I didn't confirm the guard at line 225 covers every path into it.
  • No test was added or run for this change.

Co-authored-by: topi314 <15636011+topi314@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix nil pointer dereference in gateway listen during EventResumed Guard nil SessionID when logging EventResumed in gateway listener Oct 23, 2026
Copilot AI requested a review from topi314 October 23, 2026 15:25
Comment thread gateway/gateway.go
Comment on lines +659 to +663
sessionID := ""
if g.config.SessionID != nil {
sessionID = *g.config.SessionID
}
g.config.Logger.Debug("successfully resumed", slog.String("session_id", sessionID))

This comment was marked as outdated.

Co-authored-by: topi314 <15636011+topi314@users.noreply.github.com>
@topi314
topi314 commented Oct 23, 2026
Copy link
Copy Markdown
Member

why copilot so useless kek

@topi314 topi314 closed this Oct 23, 2026
@topi314
topi314 deleted the copilot/fix-nil-pointer-dereference branch October 23, 2026 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

panic: runtime error: invalid memory address or nil pointer dereference in gateway.listen on EventResumed (gateway.go:658)

3 participants

0