Skip to content

fix: report the real error in read_from_file when docker is unavailable - #787

Open
pcbeingused333 wants to merge 1 commit into
QuantConnect:masterfrom
pcbeingused333:fix/read-from-file-unbound-p
Open

pcbeingused333 wants to merge 1 commit into
QuantConnect:masterfrom
pcbeingused333:fix/read-from-file-unbound-p

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

Fixes #783

Root cause: in DockerManager.read_from_file, the except Exception handler builds its message with p.stderr.read(), but p (the Popen object) is only assigned after get_container_by_name succeeds. When Docker is not running, get_container_by_name raises, p is unbound, and the handler itself fails with UnboundLocalError, hiding the actual error from the local lean live commands that wait for a command result (e.g. liquidate/stop).

Fix: initialise p = None on each iteration and only read its stderr when a process was started, so the original exception text is reported.

Test: test_read_from_file_reports_the_original_error_when_docker_is_unavailable fails before the change (UnboundLocalError) and passes after.

This change was prepared with AI assistance.

read_from_file referenced the Popen object p in its except handlers, but p is unassigned when get_container_by_name raises (e.g. Docker not running), masking the real error with an UnboundLocalError.
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.

Container lookup failures during result polling are masked by UnboundLocalError

1 participant