From c012094e49405223d6a068370a7540291e0b0d7b Mon Sep 17 00:00:00 2001
From: Kunal Bhattacharya <kunal.bhattacharya@pepsico.com>
Date: Sun, 7 Dec 2025 18:19:56 +0530
Subject: [PATCH] [v3-1-test] Breeze exit on incompatible arguments (#59148)

* Breeze exit on incompatible arguments

* Apply suggestion from @choo121600

Co-authored-by: Yeonguk Choo <choo121600@gmail.com>

* Nit fix

---------
(cherry picked from commit 236dab6406e55f88b879f69154e54f2763ce5d3b)

Co-authored-by: Kunal Bhattacharya <kunal.bhattacharya@pepsico.com>
Co-authored-by: Jens Scheffler <95105677+jscheffl@users.noreply.github.com>
Co-authored-by: Yeonguk Choo <choo121600@gmail.com>
---
 dev/breeze/doc/images/output_start-airflow.svg         |  2 +-
 dev/breeze/doc/images/output_start-airflow.txt         |  2 +-
 .../src/airflow_breeze/commands/developer_commands.py  | 10 +++++++++-
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/dev/breeze/doc/images/output_start-airflow.svg b/dev/breeze/doc/images/output_start-airflow.svg
index 286eefb8fe5b4..66757b5b0ca97 100644
--- a/dev/breeze/doc/images/output_start-airflow.svg
+++ b/dev/breeze/doc/images/output_start-airflow.svg
@@ -582,7 +582,7 @@
 </text><text class="breeze-start-airflow-r5" x="0" y="1557.2" textLength="12.2" clip-path="url(#breeze-start-airflow-line-63)">│</text><text class="breeze-start-airflow-r4" x="24.4" y="1557.2" textLength="305" clip-path="url(#breeze-start-airflow-line-63)">--skip-assets-compilation</text><text class="breeze-start-airflow-r1" x="378.2" y="1557.2" textLength="1061.4" clip-path="url(#breeze-start-airflow-line-63)">Skips&#160;compilation&#160;of&#160;assets&#160;when&#160;starting&#160;airflow&#160;even&#160;if&#160;the&#160;content&#160;of&#160;www&#160;changed&#160;&#160;&#160;</text><text class="breeze-start-airflow-r5" x="1451.8" y="1557.2" textLength="12.2" clip-path="url(#breeze-start-airflow-line-63)">│</text><text class="breeze-start-airflow-r1" x="1464" y="1557.2" textLength="12.2" clip-path="url(#breeze-start-airflow-line-63)">
 </text><text class="breeze-start-airflow-r5" x="0" y="1581.6" textLength="12.2" clip-path="url(#breeze-start-airflow-line-64)">│</text><text class="breeze-start-airflow-r1" x="378.2" y="1581.6" textLength="305" clip-path="url(#breeze-start-airflow-line-64)">(mutually&#160;exclusive&#160;with&#160;</text><text class="breeze-start-airflow-r4" x="683.2" y="1581.6" textLength="122" clip-path="url(#breeze-start-airflow-line-64)">--dev-mode</text><text class="breeze-start-airflow-r1" x="805.2" y="1581.6" textLength="634.4" clip-path="url(#breeze-start-airflow-line-64)">).&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</text><text class="breeze-start-airflow-r5" x="1451.8" y="1581.6" textLength="12.2" clip-path="url(#breeze-start-airflow-line-64)">│</text><text class="breeze-start-airflow-r1" x="1464" y="1581.6" textLength="12.2" clip-path="url(#breeze-start-airflow-line-64)">
 </text><text class="breeze-start-airflow-r5" x="0" y="1606" textLength="12.2" clip-path="url(#breeze-start-airflow-line-65)">│</text><text class="breeze-start-airflow-r4" x="24.4" y="1606" textLength="122" clip-path="url(#breeze-start-airflow-line-65)">--dev-mode</text><text class="breeze-start-airflow-r1" x="378.2" y="1606" textLength="1061.4" clip-path="url(#breeze-start-airflow-line-65)">Starts&#160;api-server&#160;in&#160;dev&#160;mode&#160;(assets&#160;are&#160;always&#160;recompiled&#160;in&#160;this&#160;case&#160;when&#160;starting)</text><text class="breeze-start-airflow-r5" x="1451.8" y="1606" textLength="12.2" clip-path="url(#breeze-start-airflow-line-65)">│</text><text class="breeze-start-airflow-r1" x="1464" y="1606" textLength="12.2" clip-path="url(#breeze-start-airflow-line-65)">
-</text><text class="breeze-start-airflow-r5" x="0" y="1630.4" textLength="12.2" clip-path="url(#breeze-start-airflow-line-66)">│</text><text class="breeze-start-airflow-r1" x="378.2" y="1630.4" textLength="305" clip-path="url(#breeze-start-airflow-line-66)">(mutually&#160;exclusive&#160;with&#160;</text><text class="breeze-start-airflow-r4" x="683.2" y="1630.4" textLength="305" clip-path="url(#breeze-start-airflow-line-66)">--skip-assets-compilation</text><text class="breeze-start-airflow-r1" x="988.2" y="1630.4" textLength="451.4" clip-path="url(#breeze-start-airflow-line-66)">).&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</text><text class="breeze-start-airflow-r5" x="1451.8" y="1630.4" textLength="12.2" clip-path="url(#breeze-start-airflow-line-66)">│</text><text class="breeze-start-airflow-r1" x="1464" y="1630.4" textLength="12.2" clip-path="url(#breeze-start-airflow-line-66)">
+</text><text class="breeze-start-airflow-r5" x="0" y="1630.4" textLength="12.2" clip-path="url(#breeze-start-airflow-line-66)">│</text><text class="breeze-start-airflow-r1" x="378.2" y="1630.4" textLength="305" clip-path="url(#breeze-start-airflow-line-66)">(mutually&#160;exclusive&#160;with&#160;</text><text class="breeze-start-airflow-r4" x="683.2" y="1630.4" textLength="305" clip-path="url(#breeze-start-airflow-line-66)">--skip-assets-compilation</text><text class="breeze-start-airflow-r1" x="988.2" y="1630.4" textLength="61" clip-path="url(#breeze-start-airflow-line-66)">&#160;and&#160;</text><text class="breeze-start-airflow-r4" x="1049.2" y="1630.4" textLength="256.2" clip-path="url(#breeze-start-airflow-line-66)">--use-airflow-version</text><text class="breeze-start-airflow-r1" x="1305.4" y="1630.4" textLength="134.2" clip-path="url(#breeze-start-airflow-line-66)">).&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</text><text class="breeze-start-airflow-r5" x="1451.8" y="1630.4" textLength="12.2" clip-path="url(#breeze-start-airflow-line-66)">│</text><text class="breeze-start-airflow-r1" x="1464" y="1630.4" textLength="12.2" clip-path="url(#breeze-start-airflow-line-66)">
 </text><text class="breeze-start-airflow-r5" x="0" y="1654.8" textLength="1464" clip-path="url(#breeze-start-airflow-line-67)">╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</text><text class="breeze-start-airflow-r1" x="1464" y="1654.8" textLength="12.2" clip-path="url(#breeze-start-airflow-line-67)">
 </text><text class="breeze-start-airflow-r5" x="0" y="1679.2" textLength="24.4" clip-path="url(#breeze-start-airflow-line-68)">╭─</text><text class="breeze-start-airflow-r5" x="24.4" y="1679.2" textLength="488" clip-path="url(#breeze-start-airflow-line-68)">&#160;Build&#160;CI&#160;image&#160;(before&#160;entering&#160;shell)&#160;</text><text class="breeze-start-airflow-r5" x="512.4" y="1679.2" textLength="927.2" clip-path="url(#breeze-start-airflow-line-68)">────────────────────────────────────────────────────────────────────────────</text><text class="breeze-start-airflow-r5" x="1439.6" y="1679.2" textLength="24.4" clip-path="url(#breeze-start-airflow-line-68)">─╮</text><text class="breeze-start-airflow-r1" x="1464" y="1679.2" textLength="12.2" clip-path="url(#breeze-start-airflow-line-68)">
 </text><text class="breeze-start-airflow-r5" x="0" y="1703.6" textLength="12.2" clip-path="url(#breeze-start-airflow-line-69)">│</text><text class="breeze-start-airflow-r4" x="24.4" y="1703.6" textLength="158.6" clip-path="url(#breeze-start-airflow-line-69)">--force-build</text><text class="breeze-start-airflow-r1" x="341.6" y="1703.6" textLength="707.6" clip-path="url(#breeze-start-airflow-line-69)">Force&#160;image&#160;build&#160;no&#160;matter&#160;if&#160;it&#160;is&#160;determined&#160;as&#160;needed.</text><text class="breeze-start-airflow-r5" x="1451.8" y="1703.6" textLength="12.2" clip-path="url(#breeze-start-airflow-line-69)">│</text><text class="breeze-start-airflow-r1" x="1464" y="1703.6" textLength="12.2" clip-path="url(#breeze-start-airflow-line-69)">
diff --git a/dev/breeze/doc/images/output_start-airflow.txt b/dev/breeze/doc/images/output_start-airflow.txt
index b20c774a1b108..2eabe2c3e6f67 100644
--- a/dev/breeze/doc/images/output_start-airflow.txt
+++ b/dev/breeze/doc/images/output_start-airflow.txt
@@ -1 +1 @@
-0e0e91f58cc936fdc0c2f2621f23fb3e
+6de827b3ac600a7b488313a094d227a0
diff --git a/dev/breeze/src/airflow_breeze/commands/developer_commands.py b/dev/breeze/src/airflow_breeze/commands/developer_commands.py
index 71ab14516b6fa..a32cf74ec2a9e 100644
--- a/dev/breeze/src/airflow_breeze/commands/developer_commands.py
+++ b/dev/breeze/src/airflow_breeze/commands/developer_commands.py
@@ -515,7 +515,7 @@ def shell(
 @click.option(
     "--dev-mode",
     help="Starts api-server in dev mode (assets are always recompiled in this case when starting) "
-    "(mutually exclusive with --skip-assets-compilation).",
+    "(mutually exclusive with --skip-assets-compilation and --use-airflow-version).",
     is_flag=True,
 )
 @click.option(
@@ -628,6 +628,14 @@ def start_airflow(
         )
         skip_assets_compilation = True
 
+    if dev_mode and use_airflow_version:
+        get_console().print(
+            "[error]You cannot set Airflow version in dev mode! Consider switching to the respective "
+            "version branch if you need to use --dev-mode on a different Airflow version! \nExiting!!"
+        )
+
+        sys.exit(1)
+
     # Automatically enable file polling for hot reloading under WSL
     if dev_mode and is_wsl():
         os.environ["CHOKIDAR_USEPOLLING"] = "true"
