[AI Generated] BugFix: don't assert in unsubscribe_log when handler is missing#4462
Merged
LiliDeng merged 1 commit intoMay 9, 2026
Merged
Conversation
…s missing If subscribe_log raises before create_file_handler runs (e.g. when the per-case log path can't be created), _log_file_handler stays None. The surrounding finally block in lisa_runner._deploy_environment_task still calls unsubscribe_log, which then trips `assert self._log_file_handler` and surfaces `AssertionError: Log file handler is not set`, masking the real underlying error. Skip detaching when no handler exists so the original exception propagates.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens LISA's test-result logging cleanup so a failure while creating the per-case log handler does not get replaced by a secondary AssertionError during environment-deployment cleanup. It fits into the core runner/testsuite path that manages per-case log attachment while provisioning environments and running cases.
Changes:
- Replace the
assertinTestResult.unsubscribe_logwith a defensive early return when no file handler was created. - Add inline context explaining the expected failure mode when
subscribe_logfails beforecreate_file_handler. - Preserve the original deployment or log-setup exception instead of masking it during
finallycleanup.
✅ AI Test Selection — PASSED1 test case(s) selected (view run) Marketplace image: canonical 0001-com-ubuntu-server-jammy 22_04-lts-gen2 latest
Test case details
|
johnsongeorge-w
approved these changes
May 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When deploying an environment,
lisa_runner._deploy_environment_taskdoes:subscribe_loglazily creates the per-case log file handler the first time it runs. If that creation fails (e.g. the case log directory can't be created, the path is too long on Windows, the disk is full, orrelative_to(RUN_LOCAL_LOG_PATH)raises),self._log_file_handlerstaysNone. Thefinallyblock still callsunsubscribe_log, which then trips:That
AssertionErrormasks the original deployment / log-setup error, making the real failure invisible in CI.Change
In
lisa/testsuite.py, replace theassertinunsubscribe_logwith a defensive early return when the handler was never attached. There's nothing to detach in that case, and the original exception then propagates normally.No other behavior changes.