Kaap10 opened a new pull request, #77373:
URL: https://github.com/apache/airflow/pull/77373

   <!-- SPDX-License-Identifier: Apache-2.0
        https://www.apache.org/licenses/LICENSE-2.0 -->
   
   ### Problem
   When testing a connection with `airflow connections test <conn_id>`, 
`conn.test_connection()` returns `status, message`. When the connection fails, 
`connections_test` prints the failure message using `AirflowConsole`:
   ```python
   console.print(f"[bold][red]\nConnection failed![/bold]\n{message}\n")
   ```
   
   Because `AirflowConsole` inherits from `rich.console.Console`, it parses 
markup tags (`[...]`) in printed strings by default. If `message` contains 
XML/HTML response snippets or closing tags (such as `[/error]`, `[/response]`, 
or unmatched bracket characters), Rich's parser raises 
`rich.errors.MarkupError`:
   ```text
   rich.errors.MarkupError: closing tag '[/error]' at position ... doesn't 
match any open tag
   ```
   Instead of cleanly displaying the connection failure message to the operator 
and exiting with code 1, the CLI crashes with an unhandled Python traceback.
   
   ### Solution
   1. Wrap `message` with `escape(str(message))` from `rich.markup` in 
`connection_command.py` so Rich treats it as plain text without parsing markup 
tags.
   2. Parametrize `test_cli_connections_test_fail` in 
`test_connection_command.py` to test both standard failure messages and 
messages containing closing/unmatched markup tags (e.g. `"Failed: [/error] 
[red]unmatched[/red] tag"`).
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [x] Yes - Antigravity
   
   Generated-by: Antigravity following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to