From acf1b7a3217ee262e26d6696a91212c6dce492c8 Mon Sep 17 00:00:00 2001 From: Luis Gonzalez Date: Wed, 6 May 2026 14:43:47 -0400 Subject: [PATCH 1/3] Narrow CLI exception handling in step/resume commands --- metaflow/cli_components/run_cmds.py | 2 +- metaflow/cli_components/step_cmd.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/metaflow/cli_components/run_cmds.py b/metaflow/cli_components/run_cmds.py index 82272b70568..64d7a2fa347 100644 --- a/metaflow/cli_components/run_cmds.py +++ b/metaflow/cli_components/run_cmds.py @@ -278,7 +278,7 @@ def resume( # be non-integers to avoid any clashes. This condition ensures this. try: int(run_id) - except: + except (TypeError, ValueError): pass else: raise CommandException("run-id %s cannot be an integer" % run_id) diff --git a/metaflow/cli_components/step_cmd.py b/metaflow/cli_components/step_cmd.py index 24ca9d784a0..6f7d719cf01 100644 --- a/metaflow/cli_components/step_cmd.py +++ b/metaflow/cli_components/step_cmd.py @@ -127,7 +127,7 @@ def step( func = None try: func = getattr(ctx.obj.flow, step_name) - except: + except AttributeError: raise CommandException("Step *%s* doesn't exist." % step_name) if not func.is_step: raise CommandException("Function *%s* is not a step." % step_name) From 2b88c90ccef8cce944e2afbfc25252442f452225 Mon Sep 17 00:00:00 2001 From: Luis Gonzalez Date: Tue, 12 May 2026 07:12:59 -0400 Subject: [PATCH 2/3] Narrow CLI plugin exception handling --- metaflow/plugins/cards/card_cli.py | 2 +- metaflow/plugins/logs_cli.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/metaflow/plugins/cards/card_cli.py b/metaflow/plugins/cards/card_cli.py index 9cb8b4bbb9d..0ddfc04bcf3 100644 --- a/metaflow/plugins/cards/card_cli.py +++ b/metaflow/plugins/cards/card_cli.py @@ -723,7 +723,7 @@ def create( mf_card, mode, task, data, timeout_value=timeout ) rendered_content = rendered_info.data - except: + except Exception: rendered_info = CardRenderInfo( mode=mode, is_implemented=True, diff --git a/metaflow/plugins/logs_cli.py b/metaflow/plugins/logs_cli.py index b5314bf40b6..268a6606973 100644 --- a/metaflow/plugins/logs_cli.py +++ b/metaflow/plugins/logs_cli.py @@ -36,7 +36,7 @@ def parse_args(self, ctx, args): try: super().parse_args(ctx, args) args_parseable = True - except Exception: + except click.ClickException: args_parseable = False if not args or not args_parseable: original_args.insert(0, self.default_cmd) From 5cb75b325f2fb506cb2a0e6c18213659394382b6 Mon Sep 17 00:00:00 2001 From: Luis Gonzalez <162064187+LuisJG8@users.noreply.github.com> Date: Tue, 12 May 2026 08:36:48 -0400 Subject: [PATCH 3/3] Update metaflow/plugins/logs_cli.py Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --- metaflow/plugins/logs_cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metaflow/plugins/logs_cli.py b/metaflow/plugins/logs_cli.py index 268a6606973..b5314bf40b6 100644 --- a/metaflow/plugins/logs_cli.py +++ b/metaflow/plugins/logs_cli.py @@ -36,7 +36,7 @@ def parse_args(self, ctx, args): try: super().parse_args(ctx, args) args_parseable = True - except click.ClickException: + except Exception: args_parseable = False if not args or not args_parseable: original_args.insert(0, self.default_cmd)