Skip to content

Index out of range error when converting to .har file #8188

Closed

Description

@T-aut

Problem Description

When converting .mitm flow data to a .har file, an exception is thrown in the mitmproxy/utils/strutils.py source file for specific response payloads.

Steps to reproduce the behavior:

  1. Download attached minimal reproduction .mitm flow
  2. Run mitmdump -n -r scrubbed.mitm --set hardump=./test.har
  3. Observe output

Minimal repro file:
scrubbed.mitm.zip

Stacktrace:

[13:00:52.694] Addon error: index out of range
Traceback (most recent call last):
  File "mitmproxy/addons/savehar.py", line 128, in done
  File "mitmproxy/command.py", line 322, in wrapper
  File "mitmproxy/addons/savehar.py", line 39, in export_har
  File "mitmproxy/addons/savehar.py", line 58, in make_har
  File "mitmproxy/addons/savehar.py", line 205, in flow_entry
  File "mitmproxy/utils/strutils.py", line 136, in is_mostly_bin
IndexError: index out of range

Issue is also present in mitmweb when using the command line and invoking save.har, since it uses the same /strutils.py source.

I believe the issue may have been introduced with #7933

System Information

Mitmproxy: 12.2.2 binary
Python:    3.14.3
OpenSSL:   OpenSSL 3.5.5 27 Jan 2026
Platform:  macOS-15.7.4-arm64-arm-64bit-Mach-O

Checklist

Activity

  1. added
    kind/triage
    on Apr 21, 2026
  2. added a commit that references this issue on Apr 25, 2026
    a8fbfc7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions