Skip to content

fix: replace bare except with except BaseException in check-docker.py#10407

Open
harshadkhetpal wants to merge 1 commit intolablup:mainfrom
harshadkhetpal:fix/bare-except-check-docker
Open

fix: replace bare except with except BaseException in check-docker.py#10407
harshadkhetpal wants to merge 1 commit intolablup:mainfrom
harshadkhetpal:fix/bare-except-check-docker

Conversation

@harshadkhetpal
Copy link

Summary

Replace bare except: clauses with except BaseException: in scripts/check-docker.py.

Bare except: catches all exceptions including SystemExit, KeyboardInterrupt, and GeneratorExit, which is almost never intentional. Since both affected blocks immediately re-raise a new RuntimeError, except BaseException: is the correct replacement to preserve interrupt-handling semantics while making intent explicit.

Changes (2 occurrences):

# Before
except:
    raise RuntimeError("Failed to query Snapd package information")

# After
except BaseException:
    raise RuntimeError("Failed to query Snapd package information")

Testing

No behavior change for normal exception paths — style/correctness fix only. This prevents accidentally suppressing KeyboardInterrupt / SystemExit in non-reraise scenarios.

Bare `except:` clauses catch all exceptions including SystemExit and
KeyboardInterrupt. Replace with `except BaseException:` since the
block re-raises a new RuntimeError, preserving interrupt handling
semantics while making the intent explicit.
@cla-assistant
Copy link

cla-assistant bot commented Mar 23, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

1 similar comment
@cla-assistant
Copy link

cla-assistant bot commented Mar 23, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Collaborator

@HyeockJinKim HyeockJinKim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix! However, bare except: already behaves identically to except
BaseException: — both catch everything including KeyboardInterrupt and
SystemExit. So this change doesn't affect Ctrl+C behavior.

To actually prevent suppressing keyboard interrupts, except Exception: is the
right choice here, since Exception excludes KeyboardInterrupt, SystemExit, and
GeneratorExit.

# Suggested
except Exception:
    raise RuntimeError("Failed to query Snapd package information")

# Or even better, since r.raise_for_status() only raises
# aiohttp.ClientResponseError:

except aiohttp.ClientResponseError:
    raise RuntimeError("Failed to query Snapd package information")

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.

2 participants