Skip to content

Use comma-ok type assertion for UserObject in connection handlers#461

Merged
Volte6 merged 1 commit intoGoMudEngine:masterfrom
sarahmaeve:upstream-fix/type-assertion-panic
Apr 6, 2026
Merged

Use comma-ok type assertion for UserObject in connection handlers#461
Volte6 merged 1 commit intoGoMudEngine:masterfrom
sarahmaeve:upstream-fix/type-assertion-panic

Conversation

@sarahmaeve
Copy link
Copy Markdown
Contributor

Summary

Replaces direct type assertions with comma-ok form in both telnet and WebSocket connection handlers to prevent panics.

Changes

Both handleTelnetConnection and HandleWebSocketConnection used a direct type assertion on a value from map[string]any, which will panic if the value is an unexpected type. Changed to comma-ok form with graceful error handling (log error, disconnect, break).

Test plan

  • go build passes
  • Full test suite passes

Direct type assertion uo.(*users.UserRecord) on any value from
map[string]any will panic if the value is an unexpected type.
Use comma-ok form and handle failure gracefully by logging,
removing the connection, and breaking the read loop.

Applied to both handleTelnetConnection and HandleWebSocketConnection.

Fixes #7

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sarahmaeve sarahmaeve requested a review from Volte6 as a code owner April 5, 2026 03:22
@Volte6 Volte6 merged commit 8aa3d7a into GoMudEngine:master Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants