Container lookup failures during result polling are masked by UnboundLocalError

Open Beginner friendly
#783 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@pcbeingused333 is already working on this.

Since Nov 25, 2026.

  • #787 by @pcbeingused333 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
80/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
docker, python
Domain
cli

Research direction

Start in lean/components/docker/docker_manager.py, in read_from_file: read the try block that calls get_container_by_name and Popen, then the generic except that prints p.stderr. Reproduce with a test that patches get_container_by_name to raise RuntimeError('Docker unavailable') and calls read_from_file('container', Path('result.json'), interval=0.01, timeout=0.1); done when that surfaces the original error and the existing successful-read and retry tests still pass.

Written by the indexing model from the issue text.

Description

priority:P2

Problem

DockerManager.read_from_file dereferences p.stderr in its generic exception handler even when container lookup or Popen failed before p was assigned. A Docker connection failure is consequently replaced by UnboundLocalError.

Reproduction

On current master, mock get_container_by_name to raise RuntimeError('Docker unavailable'), then call read_from_file('container', Path('result.json'), interval=0.01, timeout=0.1).

Observed: UnboundLocalError: cannot access local variable 'p' where it is not associated with a value, rather than a diagnostic of the Docker failure. The same happens if the first process cannot be started.

The relevant exception handler is in lean/components/docker/docker_manager.py, inside read_from_file.

Required result

A failure before process creation must preserve the original diagnostic and must not fail while formatting it. Existing successful reads and retry behavior must remain intact.

Dominant language
Python
Stars
335
Forks
172
Avg merge
6h 54m
Merged PRs (30d)
37

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from QuantConnect/lean-cli

All issues in QuantConnect/lean-cli

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.