Skip to content

Keep output cache valid after failed encoding requests - #814

Merged
Ousret merged 3 commits into
jawah:masterfrom
xiehuanyi:fix/output-cache-after-encoding-failure-20261013
Oct 20, 2026
Merged

Ousret merged 3 commits into
jawah:masterfrom
xiehuanyi:fix/output-cache-after-encoding-failure-20261013

Conversation

@xiehuanyi

Copy link
Copy Markdown
Contributor

A failed CharsetMatch.output() call updates the cached target encoding before encoding succeeds. Repeating the same invalid target then returns None, or bytes left from a previous successful target, instead of raising again.

Update the target encoding only after the payload has been produced successfully. Header rewriting uses the requested local encoding, so a failed charset lookup also leaves the last valid cached output intact.

The two regressions cover empty and populated caches, repeated invalid requests, and successful UTF-8/Latin-1 outputs afterward. Both fail before the change and pass after.

Validation: project nox -s test-3.12, nox -s lint, and nox -s coverage pass; the charset corpus result is 98.323% (469/477 files), above the session's 90% requirement. Testing used Python 3.12.13.

@xiehuanyi
xiehuanyi requested a review from Ousret as a code owner October 13, 2026 18:19
Copilot AI balanced review requested due to automatic review settings October 13, 2026 18:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Ousret
Ousret enabled auto-merge October 20, 2026 05:35
Ousret
Ousret previously approved these changes Oct 20, 2026
@Ousret
Ousret added this pull request to the merge queue Oct 20, 2026
@Ousret
Ousret removed this pull request from the merge queue due to the queue being cleared Oct 20, 2026
@Ousret
Ousret enabled auto-merge (squash) October 20, 2026 06:15
@Ousret
Ousret merged commit 3985662 into jawah:master Oct 20, 2026
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants