Skip to content

AttributeError: 'ConsoleMaster' object has no attribute 'loop' #8162

@glensc

Description

@glensc

Problem Description

mitmproxy shows trace when tty is not available. it should just say the error, without traceback.

mitmproxy  | 2026-04-03T15:52:30.093950862Z Traceback (most recent call last):
mitmproxy  | 2026-04-03T15:52:30.094127570Z   File "/usr/local/lib/python3.14/site-packages/mitmproxy/master.py", line 84, in run
mitmproxy  | 2026-04-03T15:52:30.094131487Z     await self.running()
mitmproxy  | 2026-04-03T15:52:30.094132987Z   File "/usr/local/lib/python3.14/site-packages/mitmproxy/tools/console/master.py", line 210, in running
mitmproxy  | 2026-04-03T15:52:30.094134404Z     sys.exit(1)
mitmproxy  | 2026-04-03T15:52:30.094135695Z     ~~~~~~~~^^^
mitmproxy  | 2026-04-03T15:52:30.094136862Z SystemExit: 1
mitmproxy  | 2026-04-03T15:52:30.094195404Z 
mitmproxy  | 2026-04-03T15:52:30.094197904Z During handling of the above exception, another exception occurred:
mitmproxy  | 2026-04-03T15:52:30.094199279Z 
mitmproxy  | 2026-04-03T15:52:30.094200445Z Traceback (most recent call last):
mitmproxy  | 2026-04-03T15:52:30.094541070Z   File "/usr/local/bin/mitmproxy", line 7, in <module>
mitmproxy  | 2026-04-03T15:52:30.094544695Z     sys.exit(mitmproxy())
mitmproxy  | 2026-04-03T15:52:30.094545987Z              ~~~~~~~~~^^
mitmproxy  | 2026-04-03T15:52:30.094547278Z   File "/usr/local/lib/python3.14/site-packages/mitmproxy/tools/main.py", line 144, in mitmproxy
mitmproxy  | 2026-04-03T15:52:30.094548653Z     run(console.master.ConsoleMaster, cmdline.mitmproxy, args)
mitmproxy  | 2026-04-03T15:52:30.094549862Z     ~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
mitmproxy  | 2026-04-03T15:52:30.094551112Z   File "/usr/local/lib/python3.14/site-packages/mitmproxy/tools/main.py", line 138, in run
mitmproxy  | 2026-04-03T15:52:30.094552362Z     return asyncio.run(main())
mitmproxy  | 2026-04-03T15:52:30.094553487Z            ~~~~~~~~~~~^^^^^^^^
mitmproxy  | 2026-04-03T15:52:30.094554653Z   File "/usr/local/lib/python3.14/asyncio/runners.py", line 204, in run
mitmproxy  | 2026-04-03T15:52:30.094555862Z     return runner.run(main)
mitmproxy  | 2026-04-03T15:52:30.094557028Z            ~~~~~~~~~~^^^^^^
mitmproxy  | 2026-04-03T15:52:30.094558195Z   File "/usr/local/lib/python3.14/asyncio/runners.py", line 127, in run
mitmproxy  | 2026-04-03T15:52:30.094559403Z     return self._loop.run_until_complete(task)
mitmproxy  | 2026-04-03T15:52:30.094560612Z            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
mitmproxy  | 2026-04-03T15:52:30.094561820Z   File "/usr/local/lib/python3.14/asyncio/base_events.py", line 719, in run_until_complete
mitmproxy  | 2026-04-03T15:52:30.094563070Z     return future.result()
mitmproxy  | 2026-04-03T15:52:30.094564195Z            ~~~~~~~~~~~~~^^
mitmproxy  | 2026-04-03T15:52:30.094567445Z   File "/usr/local/lib/python3.14/site-packages/mitmproxy/tools/main.py", line 135, in main
mitmproxy  | 2026-04-03T15:52:30.094568862Z     await master.run()
mitmproxy  | 2026-04-03T15:52:30.094570070Z   File "/usr/local/lib/python3.14/site-packages/mitmproxy/master.py", line 94, in run
mitmproxy  | 2026-04-03T15:52:30.094571362Z     await self.done()
mitmproxy  | 2026-04-03T15:52:30.094572570Z   File "/usr/local/lib/python3.14/site-packages/mitmproxy/tools/console/master.py", line 250, in done
mitmproxy  | 2026-04-03T15:52:30.094576612Z     self.loop.stop()
mitmproxy  | 2026-04-03T15:52:30.094579778Z     ^^^^^^^^^
mitmproxy  | 2026-04-03T15:52:30.094580945Z AttributeError: 'ConsoleMaster' object has no attribute 'loop'
mitmproxy  | 2026-04-03T15:52:58.043211137Z Error: mitmproxy's console interface requires a tty. Please run mitmproxy in an interactive shell environment.
services:
  proxy:
    image: mitmproxy/mitmproxy:12.2.1
    container_name: mitmproxy
    command: >
      mitmproxy
      --mode regular
      --listen-host 0.0.0.0
      --listen-port 8080
    ports:
      - "127.0.0.1:8080:8080"
    restart: unless-stopped

Steps to reproduce the behavior:

  1. Create docker-compose.yml
  2. Run docker compose up

System Information

12.2.1

Checklist

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions