fix: accept WebSocket before validation to prevent opaque 403 errors#160
Open
nioasoft wants to merge 1 commit intoAutoForgeAI:masterfrom
Open
fix: accept WebSocket before validation to prevent opaque 403 errors#160nioasoft wants to merge 1 commit intoAutoForgeAI:masterfrom
nioasoft wants to merge 1 commit intoAutoForgeAI:masterfrom
Conversation
All WebSocket endpoints now call websocket.accept() before any validation checks. Previously, closing the connection before accepting caused Starlette to return an opaque HTTP 403 instead of a meaningful error message. Changes: - Server: Accept WebSocket first, then send JSON error + close with 4xxx code if validation fails (expand, spec, assistant, terminal, main project WS) - Server: ConnectionManager.connect() no longer calls accept() to avoid double-accept - UI: Gate expand button and keyboard shortcut on hasSpec - UI: Skip WebSocket reconnection on application error codes (4000-4999) - UI: Update keyboard shortcuts help text Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
035e8fd to
dfb102d
Compare
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.
Summary
accept(), causing Starlette to return opaque HTTP 403 errors with no useful information to the clientwebsocket.accept()before all validation checks so errors are sent as JSON messages before clean close with 4xxx codeshasSpecto prevent opening the expand modal when no spec existsChanges
Server (5 files):
expand_project.py- Accept before validation + spec checkspec_creation.py- Accept before validation, fixvalidate_project_nameusageassistant_chat.py- Accept before validation, fixvalidate_project_nameusageterminal.py- Accept before all validation checkswebsocket.py- Accept before validation,ConnectionManager.connect()no longer double-acceptsClient (6 files):
useWebSocket.ts/useExpandChat.ts/useSpecChat.ts- Skip reconnection on 4xxx close codesApp.tsx- Gate expand shortcut (E key) and modal render onhasSpecKanbanBoard.tsx- Gate expand button onhasSpecKeyboardShortcutsHelp.tsx- Update E key context textTest plan
hasSpecis falsehasSpecis false🤖 Generated with Claude Code