From 26bb1c1636565f8762feba0ca7b3226716076adb Mon Sep 17 00:00:00 2001 From: ahochheiden Date: Tue, 1 Aug 2023 19:59:25 +0000 Subject: [PATCH] Bug 1846065 - Exit `DetermineCommandVenvAction` early if unknown command so that it can be gracefully handled elsewhere r=firefox-build-system-reviewers,glandium Differential Revision: https://phabricator.services.mozilla.com/D184851 --- python/mach/mach/command_util.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/python/mach/mach/command_util.py b/python/mach/mach/command_util.py index 74ecae281e32..d92bd6870daf 100644 --- a/python/mach/mach/command_util.py +++ b/python/mach/mach/command_util.py @@ -336,14 +336,20 @@ class DetermineCommandVenvAction(argparse.Action): if command == "help": return - site = "common" + command_reference = MACH_COMMANDS.get(command) + + if not command_reference: + # If there's no match for the command in the dictionary it + # means that the command doesn't exist, or that it's misspelled. + # We exit early and let both scenarios be handled elsewhere. + return if len(values) > 1: potential_sub_command_name = values[1] else: potential_sub_command_name = None - module_path = Path(self.topsrcdir) / MACH_COMMANDS.get(command).module + module_path = Path(self.topsrcdir) / command_reference.module module_dict = command_virtualenv_info_for_module(module_path) command_dict = module_dict.get(command, {})