Skip to content

Validate mitmweb flow filters on the backend - #8331

Open
lups2000 wants to merge 7 commits into
mitmproxy:mainfrom
lups2000:filters-validation-mitmweb
Open

Validate mitmweb flow filters on the backend#8331
lups2000 wants to merge 7 commits into
mitmproxy:mainfrom
lups2000:filters-validation-mitmweb

Conversation

@lups2000

@lups2000 lups2000 commented Jul 18, 2026

Copy link
Copy Markdown
Member

Description

This PR moves mitmweb flow-filter validation (search/highlight/intercept) from the frontend to the backend, making mitmproxy.flowfilter the single source of truth for filter parsing.

This adds a GET /filter/validate?expression=... endpoint that returns either the parsed filter description or a validation error.

The filter input now:

  • validates filters through the backend;
  • waits 300ms after typing before sending a request;
  • cancels obsolete requests and ignores stale responses;
  • only propagates filters after successful validation;
  • displays backend validation and request errors.

The obsolete frontend flow-filter parser (filt.js and filt.peg) has been removed.

Note

For a valid expression, flowfilter.parse() is called twice: once by the validation endpoint and again when the filter is applied by Search, Highlight, or Intercept.

This is intentional. The validation request and the operation applying the filter are independent, and the second parse keeps the existing backend paths authoritative without sharing parser objects or introducing a cache. The additional cost should be negligible.

It closes also: #8239

Checklist

  • I have updated tests where applicable.
  • I have added an entry to the CHANGELOG.

@lups2000
lups2000 requested a review from mhils July 18, 2026 10:02

@mhils mhils left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-2800 🥳🥳🥳

Comment thread mitmproxy/tools/web/app.py Outdated
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