From dba1b682d5d605b82ae108a5eb93fa709fd60cc8 Mon Sep 17 00:00:00 2001 From: Wing Fung Lau <4760060+hawflau@users.noreply.github.com> Date: Wed, 11 Jan 2023 17:11:33 -0800 Subject: [PATCH 01/16] Handled unhandled exception to show bug report message --- samcli/commands/exceptions.py | 36 +++++++++++++++++++++++++ samcli/lib/telemetry/metric.py | 16 ++++++----- tests/unit/lib/telemetry/test_metric.py | 18 ++++++------- 3 files changed, 54 insertions(+), 16 deletions(-) diff --git a/samcli/commands/exceptions.py b/samcli/commands/exceptions.py index 07229d5063..48920aa6a3 100644 --- a/samcli/commands/exceptions.py +++ b/samcli/commands/exceptions.py @@ -1,6 +1,9 @@ """ Class containing error conditions that are exposed to the user. """ +import urllib.parse +import typing as t +import traceback import click @@ -25,6 +28,39 @@ def __init__(self, message, wrapped_from=None): click.ClickException.__init__(self, message) +class UnhandledException(click.ClickException): + """ + Exception class to re-wrap any exception that is not a UserException. Typically this means there is a bug in SAM CLI. + """ + + GH_BUG_REPORT_URL = "https://github.com/aws/aws-sam-cli/issues/new?template=Bug_report.md&title={title}" + exit_code = 255 + + def __init__(self, command: str, exception: Exception) -> None: + self._command = command + self._exception = exception + self.__traceback__ = self._exception.__traceback__ + + click.ClickException.__init__(self, type(exception).__name__) + + def show(self, file: t.Optional[t.IO] = None) -> None: + if file is None: + file = click._compat.get_text_stderr() + + tb = "".join(traceback.format_tb(self.__traceback__)) + click.echo(f"\nTraceback:\n{tb}", file=file, err=True) + + url = self.GH_BUG_REPORT_URL.format( + title=urllib.parse.quote(f"{self._command} - {type(self._exception).__name__}") + ) + msg = ( + f'While trying to execute "{self._command}", we encountered an unexpected error.\n' + "To create a bug report, follow the Github issue template below:\n" + f"{url}" + ) + click.secho(msg, file=file, err=True, fg="yellow") + + class CredentialsError(UserException): """ Exception class when credentials that have been passed are invalid. diff --git a/samcli/lib/telemetry/metric.py b/samcli/lib/telemetry/metric.py index 50c13a2982..8e1b14e47b 100644 --- a/samcli/lib/telemetry/metric.py +++ b/samcli/lib/telemetry/metric.py @@ -18,7 +18,7 @@ from samcli.cli.context import Context from samcli.cli.global_config import GlobalConfig from samcli.commands._utils.experimental import get_all_experimental_statues -from samcli.commands.exceptions import UserException +from samcli.commands.exceptions import UserException, UnhandledException from samcli.lib.hook.hook_config import HookPackageConfig from samcli.lib.hook.hook_wrapper import INTERNAL_PACKAGES_ROOT from samcli.lib.hook.exceptions import InvalidHookPackageConfigException @@ -148,16 +148,18 @@ def wrapped(*args, **kwargs): # Execute the function and capture return value. This is returned back by the wrapper # First argument of all commands should be the Context return_value = func(*args, **kwargs) - except UserException as ex: + except (UserException, click.BadOptionUsage, click.BadArgumentUsage, click.BadParameter) as ex: # Capture exception information and re-raise it later so we can first send metrics. exception = ex - exit_code = ex.exit_code - if ex.wrapped_from is None: - exit_reason = type(ex).__name__ - else: + # TODO (hawflau): review exitcode meaning. We now understand exitcode 1 as errors fixable by users. + exit_code = 1 + if hasattr(ex, "wrapped_from") and ex.wrapped_from: exit_reason = ex.wrapped_from + else: + exit_reason = type(ex).__name__ except Exception as ex: - exception = ex + command = ctx.command_path if ctx else "" + exception = UnhandledException(command, ex) # Standard Unix practice to return exit code 255 on fatal/unhandled exit. exit_code = 255 exit_reason = type(ex).__name__ diff --git a/tests/unit/lib/telemetry/test_metric.py b/tests/unit/lib/telemetry/test_metric.py index afabb22b04..137d814ee3 100644 --- a/tests/unit/lib/telemetry/test_metric.py +++ b/tests/unit/lib/telemetry/test_metric.py @@ -1,15 +1,13 @@ import platform import time -from parameterized import parameterized - -import samcli - from unittest import TestCase from unittest.mock import patch, Mock, ANY, call import pytest +from parameterized import parameterized +import samcli from samcli.lib.hook.exceptions import InvalidHookPackageConfigException, InvalidHookWrapperException from samcli.lib.iac.plugins_interfaces import ProjectTypes from samcli.lib.telemetry.event import EventTracker @@ -28,7 +26,7 @@ ProjectDetails, _send_command_run_metrics, ) -from samcli.commands.exceptions import UserException +from samcli.commands.exceptions import UserException, UnhandledException class TestSendInstalledMetric(TestCase): @@ -194,7 +192,8 @@ def test_records_exceptions(self, exception, expected_exception, expected_code, def real_fn(): raise exception - with self.assertRaises(exception.__class__) as context: + expected_exception_class = exception.__class__ if isinstance(exception, UserException) else UnhandledException + with self.assertRaises(expected_exception_class) as context: track_command(real_fn)() self.assertEqual( context.exception, @@ -261,17 +260,18 @@ def func(**kwargs): ) @patch("samcli.lib.telemetry.metric.Context") @patch("samcli.lib.telemetry.metric._send_command_run_metrics") - def test_context_contains_exception(self, expected_exception, expected_code, run_metrics_mock, context_mock): - self.context_mock.exception = expected_exception("some exception") + def test_context_contains_exception(self, exception, exitcode, run_metrics_mock, context_mock): + self.context_mock.exception = exception("some exception") context_mock.get_current_context.return_value = self.context_mock mocked_func = Mock() + expected_exception = exception if exitcode == 1 else UnhandledException with self.assertRaises(expected_exception): track_command(mocked_func)() mocked_func.assert_not_called() - run_metrics_mock.assert_called_with(self.context_mock, ANY, expected_exception.__name__, expected_code) + run_metrics_mock.assert_called_with(self.context_mock, ANY, exception.__name__, exitcode) class TestSendCommandMetrics(TestCase): From 7b54934934ea2523b64a13a49a0939dfa3eba254 Mon Sep 17 00:00:00 2001 From: Wing Fung Lau <4760060+hawflau@users.noreply.github.com> Date: Wed, 11 Jan 2023 18:14:41 -0800 Subject: [PATCH 02/16] Fix linting issues --- samcli/commands/exceptions.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/samcli/commands/exceptions.py b/samcli/commands/exceptions.py index 48920aa6a3..ea924a7225 100644 --- a/samcli/commands/exceptions.py +++ b/samcli/commands/exceptions.py @@ -30,7 +30,8 @@ def __init__(self, message, wrapped_from=None): class UnhandledException(click.ClickException): """ - Exception class to re-wrap any exception that is not a UserException. Typically this means there is a bug in SAM CLI. + Exception class to re-wrap any exception that is not a UserException. + Typically this means there is a bug in SAM CLI. """ GH_BUG_REPORT_URL = "https://github.com/aws/aws-sam-cli/issues/new?template=Bug_report.md&title={title}" @@ -44,8 +45,9 @@ def __init__(self, command: str, exception: Exception) -> None: click.ClickException.__init__(self, type(exception).__name__) def show(self, file: t.Optional[t.IO] = None) -> None: + """Overriding show to customize printing stack trace and message""" if file is None: - file = click._compat.get_text_stderr() + file = click._compat.get_text_stderr() # pylint: disable=protected-access tb = "".join(traceback.format_tb(self.__traceback__)) click.echo(f"\nTraceback:\n{tb}", file=file, err=True) From 014eeb0d3d72df3d243593afd5c5557b6f1e6dcb Mon Sep 17 00:00:00 2001 From: Wing Fung Lau <4760060+hawflau@users.noreply.github.com> Date: Wed, 11 Jan 2023 18:25:06 -0800 Subject: [PATCH 03/16] run black reformat --- samcli/commands/exceptions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samcli/commands/exceptions.py b/samcli/commands/exceptions.py index ea924a7225..cc5e5aed04 100644 --- a/samcli/commands/exceptions.py +++ b/samcli/commands/exceptions.py @@ -47,7 +47,7 @@ def __init__(self, command: str, exception: Exception) -> None: def show(self, file: t.Optional[t.IO] = None) -> None: """Overriding show to customize printing stack trace and message""" if file is None: - file = click._compat.get_text_stderr() # pylint: disable=protected-access + file = click._compat.get_text_stderr() # pylint: disable=protected-access tb = "".join(traceback.format_tb(self.__traceback__)) click.echo(f"\nTraceback:\n{tb}", file=file, err=True) From e9cd81fcc0a9589ed2639584eb26bb1b099c52dd Mon Sep 17 00:00:00 2001 From: Wing Fung Lau <4760060+hawflau@users.noreply.github.com> Date: Wed, 11 Jan 2023 19:24:01 -0800 Subject: [PATCH 04/16] Update message text and add unit test --- samcli/commands/exceptions.py | 2 +- tests/unit/commands/test_exceptions.py | 31 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 tests/unit/commands/test_exceptions.py diff --git a/samcli/commands/exceptions.py b/samcli/commands/exceptions.py index cc5e5aed04..5fa19f7299 100644 --- a/samcli/commands/exceptions.py +++ b/samcli/commands/exceptions.py @@ -56,7 +56,7 @@ def show(self, file: t.Optional[t.IO] = None) -> None: title=urllib.parse.quote(f"{self._command} - {type(self._exception).__name__}") ) msg = ( - f'While trying to execute "{self._command}", we encountered an unexpected error.\n' + f'An unexpected error was encountered while executing "{self._command}".\n' "To create a bug report, follow the Github issue template below:\n" f"{url}" ) diff --git a/tests/unit/commands/test_exceptions.py b/tests/unit/commands/test_exceptions.py new file mode 100644 index 0000000000..eaa07ba0d2 --- /dev/null +++ b/tests/unit/commands/test_exceptions.py @@ -0,0 +1,31 @@ +import io + +from unittest import TestCase +from unittest.mock import patch, Mock + + +from samcli.commands.exceptions import UnhandledException + + +class TestUnhandledException(TestCase): + def test_show_must_print_traceback_and_message(self): + wrapped_exception = None + try: + raise Exception("my_exception") + except Exception as e: + wrapped_exception = e + + unhandled_exception = UnhandledException("test_command", wrapped_exception) + f = io.StringIO() + unhandled_exception.show(f) + + output = f.getvalue() + + self.assertIn("Traceback:", output) + self.assertIn("raise Exception(\"my_exception\")", output) + self.assertIn( + 'An unexpected error was encountered while executing "test_command".\n' + "To create a bug report, follow the Github issue template below:\n" + "https://github.com/aws/aws-sam-cli/issues/new?template=Bug_report.md&title=test_command%20-%20Exception", + output + ) From 32d13cdd5820533b1ecd74c80493b86ce0bf4d27 Mon Sep 17 00:00:00 2001 From: Wing Fung Lau <4760060+hawflau@users.noreply.github.com> Date: Wed, 11 Jan 2023 19:31:33 -0800 Subject: [PATCH 05/16] Run black reformat --- tests/unit/commands/test_exceptions.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit/commands/test_exceptions.py b/tests/unit/commands/test_exceptions.py index eaa07ba0d2..97435a6ac9 100644 --- a/tests/unit/commands/test_exceptions.py +++ b/tests/unit/commands/test_exceptions.py @@ -20,12 +20,12 @@ def test_show_must_print_traceback_and_message(self): unhandled_exception.show(f) output = f.getvalue() - + self.assertIn("Traceback:", output) - self.assertIn("raise Exception(\"my_exception\")", output) + self.assertIn('raise Exception("my_exception")', output) self.assertIn( 'An unexpected error was encountered while executing "test_command".\n' "To create a bug report, follow the Github issue template below:\n" "https://github.com/aws/aws-sam-cli/issues/new?template=Bug_report.md&title=test_command%20-%20Exception", - output + output, ) From e152124279a52e988b48197ec7621b4ce382f39c Mon Sep 17 00:00:00 2001 From: Wing Fung Lau <4760060+hawflau@users.noreply.github.com> Date: Wed, 11 Jan 2023 19:50:33 -0800 Subject: [PATCH 06/16] add test cases --- tests/unit/lib/telemetry/test_metric.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/unit/lib/telemetry/test_metric.py b/tests/unit/lib/telemetry/test_metric.py index 137d814ee3..4e0a0ea22d 100644 --- a/tests/unit/lib/telemetry/test_metric.py +++ b/tests/unit/lib/telemetry/test_metric.py @@ -5,6 +5,7 @@ from unittest.mock import patch, Mock, ANY, call import pytest +import click from parameterized import parameterized import samcli @@ -182,6 +183,9 @@ def real_fn(): (KeyError("IO Error test"), "KeyError", 255), (UserException("Something went wrong", wrapped_from="CustomException"), "CustomException", 1), (UserException("Something went wrong"), "UserException", 1), + (click.BadOptionUsage("--my-opt", "Wrong option usage"), "BadOptionUsage", 1), + (click.BadArgumentUsage("Wrong argument usage"), "BadArgumentUsage", 1), + (click.BadParameter("Bad param"), "BadParameter", 1), ] ) @patch("samcli.lib.telemetry.metric.Context") @@ -192,13 +196,13 @@ def test_records_exceptions(self, exception, expected_exception, expected_code, def real_fn(): raise exception - expected_exception_class = exception.__class__ if isinstance(exception, UserException) else UnhandledException + expected_exception_class = exception.__class__ if expected_code != 255 else UnhandledException with self.assertRaises(expected_exception_class) as context: track_command(real_fn)() self.assertEqual( context.exception, exception, - "Must re-raise the original exception object " "without modification", + "Must re-raise the original exception object without modification", ) run_metrics_mock.assert_called_with(self.context_mock, ANY, expected_exception, expected_code) @@ -256,12 +260,18 @@ def func(**kwargs): (KeyError, 255), (UserException, 1), (InvalidHookWrapperException, 1), + (click.BadOptionUsage, 1), + (click.BadArgumentUsage, 1), + (click.BadParameter, 1), ] ) @patch("samcli.lib.telemetry.metric.Context") @patch("samcli.lib.telemetry.metric._send_command_run_metrics") def test_context_contains_exception(self, exception, exitcode, run_metrics_mock, context_mock): - self.context_mock.exception = exception("some exception") + if exception == click.BadOptionUsage: + self.context_mock.exception = exception("--opt", "some exception") + else: + self.context_mock.exception = exception("some exception") context_mock.get_current_context.return_value = self.context_mock mocked_func = Mock() From 6389ed0391d8ee8308102c6ecc21720ea47a5eee Mon Sep 17 00:00:00 2001 From: Wing Fung Lau <4760060+hawflau@users.noreply.github.com> Date: Thu, 12 Jan 2023 00:00:53 -0800 Subject: [PATCH 07/16] Update actual exitcode of UnhandledException to 1 to not break existing behavior --- samcli/commands/exceptions.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/samcli/commands/exceptions.py b/samcli/commands/exceptions.py index 5fa19f7299..b5b0521a59 100644 --- a/samcli/commands/exceptions.py +++ b/samcli/commands/exceptions.py @@ -35,7 +35,8 @@ class UnhandledException(click.ClickException): """ GH_BUG_REPORT_URL = "https://github.com/aws/aws-sam-cli/issues/new?template=Bug_report.md&title={title}" - exit_code = 255 + # NOTE (hawflau): actual exitcode is 1 to not break existing behavior. Only report 255 to telemetry + exit_code = 1 def __init__(self, command: str, exception: Exception) -> None: self._command = command From afb4e70cbea65f34c79420d69630794225ba3834 Mon Sep 17 00:00:00 2001 From: Wing Fung Lau <4760060+hawflau@users.noreply.github.com> Date: Thu, 12 Jan 2023 08:42:21 -0800 Subject: [PATCH 08/16] remove unused import --- tests/unit/lib/telemetry/test_metric.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/unit/lib/telemetry/test_metric.py b/tests/unit/lib/telemetry/test_metric.py index 4e0a0ea22d..5e1e59b672 100644 --- a/tests/unit/lib/telemetry/test_metric.py +++ b/tests/unit/lib/telemetry/test_metric.py @@ -8,7 +8,6 @@ import click from parameterized import parameterized -import samcli from samcli.lib.hook.exceptions import InvalidHookPackageConfigException, InvalidHookWrapperException from samcli.lib.iac.plugins_interfaces import ProjectTypes from samcli.lib.telemetry.event import EventTracker From aed9dea61f8c696744b038aaacaa68c63409ec6f Mon Sep 17 00:00:00 2001 From: Wing Fung Lau <4760060+hawflau@users.noreply.github.com> Date: Thu, 12 Jan 2023 16:06:29 -0800 Subject: [PATCH 09/16] address feedback --- samcli/commands/exceptions.py | 10 ++++------ samcli/lib/telemetry/metric.py | 8 +++++++- tests/unit/lib/telemetry/test_metric.py | 2 ++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/samcli/commands/exceptions.py b/samcli/commands/exceptions.py index b5b0521a59..8a869341f1 100644 --- a/samcli/commands/exceptions.py +++ b/samcli/commands/exceptions.py @@ -1,9 +1,9 @@ """ Class containing error conditions that are exposed to the user. """ -import urllib.parse -import typing as t import traceback +from urllib.parse import quote +from typing import Optional, IO import click @@ -45,7 +45,7 @@ def __init__(self, command: str, exception: Exception) -> None: click.ClickException.__init__(self, type(exception).__name__) - def show(self, file: t.Optional[t.IO] = None) -> None: + def show(self, file: Optional[IO] = None) -> None: """Overriding show to customize printing stack trace and message""" if file is None: file = click._compat.get_text_stderr() # pylint: disable=protected-access @@ -53,9 +53,7 @@ def show(self, file: t.Optional[t.IO] = None) -> None: tb = "".join(traceback.format_tb(self.__traceback__)) click.echo(f"\nTraceback:\n{tb}", file=file, err=True) - url = self.GH_BUG_REPORT_URL.format( - title=urllib.parse.quote(f"{self._command} - {type(self._exception).__name__}") - ) + url = self.GH_BUG_REPORT_URL.format(title=quote(f"{self._command} - {type(self._exception).__name__}")) msg = ( f'An unexpected error was encountered while executing "{self._command}".\n' "To create a bug report, follow the Github issue template below:\n" diff --git a/samcli/lib/telemetry/metric.py b/samcli/lib/telemetry/metric.py index 8e1b14e47b..86f97fe18a 100644 --- a/samcli/lib/telemetry/metric.py +++ b/samcli/lib/telemetry/metric.py @@ -148,7 +148,13 @@ def wrapped(*args, **kwargs): # Execute the function and capture return value. This is returned back by the wrapper # First argument of all commands should be the Context return_value = func(*args, **kwargs) - except (UserException, click.BadOptionUsage, click.BadArgumentUsage, click.BadParameter) as ex: + except ( + UserException, + click.BadOptionUsage, + click.BadArgumentUsage, + click.BadParameter, + click.UsageError, + ) as ex: # Capture exception information and re-raise it later so we can first send metrics. exception = ex # TODO (hawflau): review exitcode meaning. We now understand exitcode 1 as errors fixable by users. diff --git a/tests/unit/lib/telemetry/test_metric.py b/tests/unit/lib/telemetry/test_metric.py index 5e1e59b672..fa002aebc2 100644 --- a/tests/unit/lib/telemetry/test_metric.py +++ b/tests/unit/lib/telemetry/test_metric.py @@ -185,6 +185,7 @@ def real_fn(): (click.BadOptionUsage("--my-opt", "Wrong option usage"), "BadOptionUsage", 1), (click.BadArgumentUsage("Wrong argument usage"), "BadArgumentUsage", 1), (click.BadParameter("Bad param"), "BadParameter", 1), + (click.UsageError("UsageError"), "UsageError", 1), ] ) @patch("samcli.lib.telemetry.metric.Context") @@ -262,6 +263,7 @@ def func(**kwargs): (click.BadOptionUsage, 1), (click.BadArgumentUsage, 1), (click.BadParameter, 1), + (click.UsageError, 1), ] ) @patch("samcli.lib.telemetry.metric.Context") From 1e5a2252a2cd8a507e54cf6da9dd9033f42f68b8 Mon Sep 17 00:00:00 2001 From: Wing Fung Lau <4760060+hawflau@users.noreply.github.com> Date: Fri, 13 Jan 2023 15:41:54 -0800 Subject: [PATCH 10/16] Update messaging --- samcli/commands/exceptions.py | 11 ++++++++--- tests/unit/commands/test_exceptions.py | 6 ++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/samcli/commands/exceptions.py b/samcli/commands/exceptions.py index 8a869341f1..3de928060b 100644 --- a/samcli/commands/exceptions.py +++ b/samcli/commands/exceptions.py @@ -34,6 +34,7 @@ class UnhandledException(click.ClickException): Typically this means there is a bug in SAM CLI. """ + GH_ISSUE_SEARCH_URL = "https://github.com/aws/aws-sam-cli/issues?q=is%3Aissue+is%3Aopen+{title}" GH_BUG_REPORT_URL = "https://github.com/aws/aws-sam-cli/issues/new?template=Bug_report.md&title={title}" # NOTE (hawflau): actual exitcode is 1 to not break existing behavior. Only report 255 to telemetry exit_code = 1 @@ -53,11 +54,15 @@ def show(self, file: Optional[IO] = None) -> None: tb = "".join(traceback.format_tb(self.__traceback__)) click.echo(f"\nTraceback:\n{tb}", file=file, err=True) - url = self.GH_BUG_REPORT_URL.format(title=quote(f"{self._command} - {type(self._exception).__name__}")) + encoded_title = quote(f"Bug: {self._command} - {type(self._exception).__name__}") + lookup_url = self.GH_ISSUE_SEARCH_URL.format(title=encoded_title) + create_issue_url = self.GH_BUG_REPORT_URL.format(title=encoded_title) msg = ( f'An unexpected error was encountered while executing "{self._command}".\n' - "To create a bug report, follow the Github issue template below:\n" - f"{url}" + "Search if there is any existing issue:\n" + f"{lookup_url}\n" + "Or create a bug report:\n" + f"{create_issue_url}" ) click.secho(msg, file=file, err=True, fg="yellow") diff --git a/tests/unit/commands/test_exceptions.py b/tests/unit/commands/test_exceptions.py index 97435a6ac9..da9c3bba34 100644 --- a/tests/unit/commands/test_exceptions.py +++ b/tests/unit/commands/test_exceptions.py @@ -25,7 +25,9 @@ def test_show_must_print_traceback_and_message(self): self.assertIn('raise Exception("my_exception")', output) self.assertIn( 'An unexpected error was encountered while executing "test_command".\n' - "To create a bug report, follow the Github issue template below:\n" - "https://github.com/aws/aws-sam-cli/issues/new?template=Bug_report.md&title=test_command%20-%20Exception", + "Search if there is any existing issue:\n" + "https://github.com/aws/aws-sam-cli/issues?q=is%3Aissue+is%3Aopen+Bug%3A%20test_command%20-%20Exception\n" + "Or create a bug report:\n" + "https://github.com/aws/aws-sam-cli/issues/new?template=Bug_report.md&title=Bug%3A%20test_command%20-%20Exception", output, ) From 1704fc546793093ead28ec71bbe8ca1f1d4ccbf9 Mon Sep 17 00:00:00 2001 From: Wing Fung Lau <4760060+hawflau@users.noreply.github.com> Date: Fri, 13 Jan 2023 15:55:20 -0800 Subject: [PATCH 11/16] Update Unit Tests GH Action to make sure Bug_report.md exists --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 091d1f7d95..ededa8294c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,5 +25,6 @@ jobs: - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python }} + - run: test -f "./.github/ISSUE_TEMPLATE/Bug_report.md" # prevent Bug_report.md from being changed or deleted - run: make init - run: make pr From 2581d59748bcf77bb6866242bccd7a8f473dab1a Mon Sep 17 00:00:00 2001 From: Wing Fung Lau <4760060+hawflau@users.noreply.github.com> Date: Fri, 13 Jan 2023 16:09:16 -0800 Subject: [PATCH 12/16] Update bug report --- .github/ISSUE_TEMPLATE/Bug_report.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/Bug_report.md b/.github/ISSUE_TEMPLATE/Bug_report.md index 656e4106db..1941ae0941 100644 --- a/.github/ISSUE_TEMPLATE/Bug_report.md +++ b/.github/ISSUE_TEMPLATE/Bug_report.md @@ -32,8 +32,10 @@ If you do find an existing Issue, re-open or add a comment to that Issue instead ### Additional environment details (Ex: Windows, Mac, Amazon Linux etc) -1. OS: -2. `sam --version`: -3. AWS region: +1. AWS region: +2. `sam --info`: +``` +# Paste the output of `sam --info` here +``` `Add --debug flag to command you are running` From 569d52cd0974deac7e5d613275ab6d8a93a6468b Mon Sep 17 00:00:00 2001 From: Wing Fung Lau <4760060+hawflau@users.noreply.github.com> Date: Tue, 17 Jan 2023 08:36:33 -0800 Subject: [PATCH 13/16] Update Bug Report template --- .github/ISSUE_TEMPLATE/Bug_report.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/Bug_report.md b/.github/ISSUE_TEMPLATE/Bug_report.md index 1941ae0941..4766a9eb92 100644 --- a/.github/ISSUE_TEMPLATE/Bug_report.md +++ b/.github/ISSUE_TEMPLATE/Bug_report.md @@ -32,8 +32,12 @@ If you do find an existing Issue, re-open or add a comment to that Issue instead ### Additional environment details (Ex: Windows, Mac, Amazon Linux etc) -1. AWS region: -2. `sam --info`: + + +1. OS: +2. `sam --version`: +3. AWS region: + ``` # Paste the output of `sam --info` here ``` From c7c6a6661fa568c64e4ca02ce3e3add917f6cebe Mon Sep 17 00:00:00 2001 From: Wing Fung Lau <4760060+hawflau@users.noreply.github.com> Date: Tue, 17 Jan 2023 08:47:54 -0800 Subject: [PATCH 14/16] fix typo --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ededa8294c..e2901ec348 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,6 +25,6 @@ jobs: - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python }} - - run: test -f "./.github/ISSUE_TEMPLATE/Bug_report.md" # prevent Bug_report.md from being changed or deleted + - run: test -f "./.github/ISSUE_TEMPLATE/Bug_report.md" # prevent Bug_report.md from being renamed or deleted - run: make init - run: make pr From bcd446631174a29ebc5de9c0b63725275a6c4aac Mon Sep 17 00:00:00 2001 From: Wing Fung Lau <4760060+hawflau@users.noreply.github.com> Date: Tue, 17 Jan 2023 11:56:17 -0800 Subject: [PATCH 15/16] Update wording --- samcli/commands/exceptions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samcli/commands/exceptions.py b/samcli/commands/exceptions.py index 3de928060b..ea409c40e2 100644 --- a/samcli/commands/exceptions.py +++ b/samcli/commands/exceptions.py @@ -59,7 +59,7 @@ def show(self, file: Optional[IO] = None) -> None: create_issue_url = self.GH_BUG_REPORT_URL.format(title=encoded_title) msg = ( f'An unexpected error was encountered while executing "{self._command}".\n' - "Search if there is any existing issue:\n" + "Search for an existing issue:\n" f"{lookup_url}\n" "Or create a bug report:\n" f"{create_issue_url}" From d651acce233846c633fe62fb248a35e92c67432a Mon Sep 17 00:00:00 2001 From: Wing Fung Lau <4760060+hawflau@users.noreply.github.com> Date: Tue, 17 Jan 2023 12:49:39 -0800 Subject: [PATCH 16/16] update test --- tests/unit/commands/test_exceptions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/commands/test_exceptions.py b/tests/unit/commands/test_exceptions.py index da9c3bba34..62104cf0b6 100644 --- a/tests/unit/commands/test_exceptions.py +++ b/tests/unit/commands/test_exceptions.py @@ -25,7 +25,7 @@ def test_show_must_print_traceback_and_message(self): self.assertIn('raise Exception("my_exception")', output) self.assertIn( 'An unexpected error was encountered while executing "test_command".\n' - "Search if there is any existing issue:\n" + "Search for an existing issue:\n" "https://github.com/aws/aws-sam-cli/issues?q=is%3Aissue+is%3Aopen+Bug%3A%20test_command%20-%20Exception\n" "Or create a bug report:\n" "https://github.com/aws/aws-sam-cli/issues/new?template=Bug_report.md&title=Bug%3A%20test_command%20-%20Exception",