When server replay is configured without server_replay_reuse (the default), consuming the final replayable response empties the replay map. Every later request then bypasses server_replay_extra because the extra-request policy is gated behind if self.flowmap:.
This contradicts the option's documented contract: server_replay_extra controls requests during replay for which no replayable response was found. It also makes numeric policies such as 404 stop applying silently after the last saved response is consumed.
Changes
mitmproxy/addons/serverplayback.py: Move the server_replay_extra handling (kill, return synthetic status code) outside the if self.flowmap: guard. After a matched replay flow is served, the function returns early. If no match is found (or the flowmap is empty), the configured extra-request policy is applied.
Tests
test/mitmproxy/addons/test_serverplayback.py: Add test_server_playback_extra_after_exhaustion — loads one flow, consumes it, then verifies that the configured server_replay_extra policy (204, 400, 404, 500) is still applied to the next request.
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
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.
Description
When server replay is configured without server_replay_reuse (the default), consuming the final replayable response empties the replay map. Every later request then bypasses server_replay_extra because the extra-request policy is gated behind if self.flowmap:.
This contradicts the option's documented contract: server_replay_extra controls requests during replay for which no replayable response was found. It also makes numeric policies such as 404 stop applying silently after the last saved response is consumed.
Changes
Tests
Closes #8363