Skip to content

Fix #8239: mitmweb WebSocket crash on invalid filter expression#8250

Open
ErnestHysa wants to merge 2 commits into
mitmproxy:mainfrom
ErnestHysa:fix-8239-websocket-crash-on-invalid-filter
Open

Fix #8239: mitmweb WebSocket crash on invalid filter expression#8250
ErnestHysa wants to merge 2 commits into
mitmproxy:mainfrom
ErnestHysa:fix-8239-websocket-crash-on-invalid-filter

Conversation

@ErnestHysa
Copy link
Copy Markdown

Fixes issue #8239: mitmweb disconnects on unmatched quote in filter.

When mitmweb receives an invalid filter expression (e.g., with unmatched quotes), the WebSocket connection would crash because flowfilter.parse() raises a ValueError that was not being caught in update_filter().

ErnestHysa and others added 2 commits May 31, 2026 17:26
Wrap filter parsing in try/except to catch ValueError from invalid
filter expressions (e.g., unmatched quotes) and return an error message
to the client instead of crashing the WebSocket connection.

The error is returned as a flows/filterError message with the filter
name and error description, allowing the client to display feedback
without losing the connection.
@mhils mhils requested a review from lups2000 June 1, 2026 08:43
@lups2000
Copy link
Copy Markdown
Member

lups2000 commented Jun 5, 2026

Thanks for the PR, I would just put it in stand by because I would like to clarify first something related to filters that I mentioned in #8245 :)

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