From eae31c02271ce4490c64e98b5cb8db6072d26ab2 Mon Sep 17 00:00:00 2001 From: "Fabio M. Graetz, Ph.D." Date: Wed, 24 Jul 2024 19:53:17 +0200 Subject: [PATCH] Feat: Make exception raised by external command authenticator more actionable (#2594) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabio Grätz Co-authored-by: Fabio Grätz --- flytekit/clients/auth/authenticator.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/flytekit/clients/auth/authenticator.py b/flytekit/clients/auth/authenticator.py index 95a89422be..f3944ecbfa 100644 --- a/flytekit/clients/auth/authenticator.py +++ b/flytekit/clients/auth/authenticator.py @@ -179,12 +179,15 @@ def refresh_credentials(self): This function is used when the configuration value for AUTH_MODE is set to 'external_process'. It reads an id token generated by an external process started by running the 'command'. """ - logging.debug("Starting external process to generate id token. Command {}".format(self._cmd)) + cmd_joined = " ".join(self._cmd) + logging.debug("Starting external process to generate id token. Command `{}`".format(" ".join(cmd_joined))) try: output = subprocess.run(self._cmd, capture_output=True, text=True, check=True) - except subprocess.CalledProcessError as e: - logging.error("Failed to generate token from command {}".format(self._cmd)) - raise AuthenticationError("Problems refreshing token with command: " + str(e)) + except subprocess.CalledProcessError: + logging.error("Failed to generate token from command `{}`".format(cmd_joined)) + raise AuthenticationError( + f"Failed to refresh token with command `{cmd_joined}`. Please execute this command in your terminal to debug." + ) self._creds = Credentials(output.stdout.strip())