You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Alternatives of a middleware step (custom.middlewares, a list of
lists) share one mutable request. MiddlewareHandler.apply_middlewares()
passes the same flask.Request to each alternative; an alternative that
changes the JSON body (request.json) and then raises leaves its partial
changes for the next alternative, which then works on a task that no one
intended (found in the plugin design review, plugin-architecture.md
2.1).
Proposal
Copy the body before each step; after a failed alternative, restore it
in place (middlewares change request.json in place, which Flask parses
once per request), so every alternative starts from the body as it was
before the step. The middleware interface stays as it is (the interface
change is #315).
Acceptance criteria
A test with an alternative that changes the body and raises,
twice, before a working one: the result has only the working
alternative's change (fails without the fix).
Docs (docs/middlewares.md): changes of failed middlewares are
undone; middlewares change the body in place.
ruff check, ruff format --check, mypy (77 files), ast-grep scan
rule tests, semgrep --config=.semgrep, coverage run -m pytest
(1037 passed, 80 skipped: chart tests without helm and real-MongoDB
tests; 100%), mkdocs build --strict. Not run: the Docker Compose smoke
test and the MongoDB 7.0 matrix entry (CI runs them).
Activity