diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 7212123d22..0cc771a9a7 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -52,6 +52,7 @@ * Improved error message in `snow spcs image-registry login` when docker is not installed. * Improved detection of conflicts between artifact rules for native application projects * Fixed URL generation for applications, streamlits, and notebooks that use a quoted identifier with spaces. +* Fixes markup escaping errors in `snow sql` that may occur when users use unintentionally markup-like escape tags. # v2.4.0 ## Backward incompatibility diff --git a/src/snowflake/cli/app/printing.py b/src/snowflake/cli/app/printing.py index 390cdb555e..b501c9e473 100644 --- a/src/snowflake/cli/app/printing.py +++ b/src/snowflake/cli/app/printing.py @@ -42,6 +42,9 @@ # ensure we do not break URLs that wrap lines get_console().soft_wrap = True +# Disable markup to avoid escaping errors +get_console()._markup = False # noqa: SLF001 + class CustomJSONEncoder(JSONEncoder): """Custom JSON encoder handling serialization of non-standard types""" diff --git a/tests/output/test_printing.py b/tests/output/test_printing.py index 29cc9d921a..f91edca34d 100644 --- a/tests/output/test_printing.py +++ b/tests/output/test_printing.py @@ -100,6 +100,29 @@ def test_single_collection_result(capsys, mock_cursor): ) +def test_print_markup_tags_in_output_do_not_raise_errors(capsys, mock_cursor): + output_data = QueryResult( + mock_cursor( + columns=["CONCAT('[INST]','FOO', 'TRANSCRIPT','[/INST]')"], + rows=[ + ("[INST]footranscript[/INST]",), + ], + ) + ) + print_result(output_data, output_format=OutputFormat.TABLE) + + assert get_output(capsys) == dedent( + """\ + SELECT A MOCK QUERY + +------------------------------------------------+ + | CONCAT('[INST]','FOO', 'TRANSCRIPT','[/INST]') | + |------------------------------------------------| + | [INST]footranscript[/INST] | + +------------------------------------------------+ + """ + ) + + def test_print_multi_results_table(capsys, _create_mock_cursor): output_data = MultipleResults( [