Skip to content

Preserve zero-valued fields in cuts and saved output - #8533

Closed
hakarrr wants to merge 5 commits into
mitmproxy:mainfrom
hakarrr:fix/preserve-zero-cuts
Closed

hakarrr wants to merge 5 commits into
mitmproxy:mainfrom
hakarrr:fix/preserve-zero-cuts

Conversation

@hakarrr

@hakarrr hakarrr commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Description

Cut extraction ends with str(current or ""), so numeric zero is silently exported as an empty string. This affects fields such as DNS transaction ID0, DNS response code0(NOERROR), and zero-valued timestamps. Both single-value saves and CSV output lose those values.

Only treat None as missing before the final string conversion. Existing dedicated handling for bytes, booleans, headers and certificates is unchanged. Other values follow the documented string conversion, including empty containers rather than treating them as absent.

Tests cover integer/floating zero timestamps, DNS ID/response code zero, missing-value compatibility, and single-value/CSV saves. Four new cases fail on unchanged source.

  • Cut tests:15 passed.
  • Addons tests:544 passed,1 skipped.
  • Non-addon tests:1479 passed,1 skipped,1 TUN-device permission failure. That TUN failure also reproduces with the unchanged cut source.
  • uv run --no-sync tox -e lint and changed Python files' format check pass.

Tests used the existing environment with --no-sync; the latest dependency-lock updates were not installed for this run.

Checklist

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

hakarrr and others added 5 commits October 26, 2026 03:21
Only map missing values to an empty string, instead of treating numeric zero as missing.

Co-authored-by: generaltony007 <[email protected]>
Cover integer and floating zero timestamps, DNS transaction ID and NOERROR code zero, single-value and CSV saves, and missing-value compatibility.

Co-authored-by: generaltony007 <[email protected]>
Note the cut and cut.save zero-value data-loss fix.

Co-authored-by: generaltony007 <[email protected]>
@hakarrr

hakarrr commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

Could a maintainer review the zero-valued cut and saved-output field fix and let me know the next step? Please point out any changes needed before human review, or let me know if you'd prefer this PR closed. Thanks.

@hakarrr hakarrr closed this Nov 17, 2026
@hakarrr
hakarrr deleted the fix/preserve-zero-cuts branch November 25, 2026 06:22
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.

1 participant