This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 419ac06e8ac Fix scheduled CI upgrade failing when its PR already 
exists (#69018)
419ac06e8ac is described below

commit 419ac06e8ac3dec8bd80716bde915b5f166623a8
Author: Shahar Epstein <[email protected]>
AuthorDate: Fri Jun 26 22:22:13 2026 +0300

    Fix scheduled CI upgrade failing when its PR already exists (#69018)
    
    The scheduled "breeze ci upgrade" job force-pushes a stable branch
    (ci-upgrade-<branch>) and then looks for an existing PR before creating
    one. The lookup passed the "owner:branch" head label to "gh pr list
    --head", but that flag filters by the bare branch name only and does not
    support the "owner:branch" syntax, so the existing PR was never found and
    the job fell through to "gh pr create" — which rejected the duplicate and
    failed the run.
    
    Use the bare branch name for the "gh pr list" and "gh pr ready" lookups
    (only "gh pr create --head" needs the cross-fork "owner:branch" label),
    and treat an "already exists" creation error as success since the branch
    has already been force-pushed.
---
 .../src/airflow_breeze/commands/ci_commands.py      | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/dev/breeze/src/airflow_breeze/commands/ci_commands.py 
b/dev/breeze/src/airflow_breeze/commands/ci_commands.py
index 46c1588827d..686def2fc0b 100644
--- a/dev/breeze/src/airflow_breeze/commands/ci_commands.py
+++ b/dev/breeze/src/airflow_breeze/commands/ci_commands.py
@@ -906,7 +906,9 @@ def upgrade(
         pr_title = f"[{target_branch}] Upgrade important CI environment"
         pr_body = "This PR upgrades important dependencies of the CI 
environment."
 
-        # Check if there's already an open PR for this branch
+        # Check if there's already an open PR for this branch.
+        # gh pr list / gh pr ready filter by the bare head-branch name, not the
+        # "owner:branch" label that gh pr create needs for cross-fork PRs.
         existing_pr_result = run_command(
             [
                 "gh",
@@ -915,7 +917,7 @@ def upgrade(
                 "--repo",
                 "apache/airflow",
                 "--head",
-                head_ref,
+                branch_name,
                 "--base",
                 target_branch,
                 "--state",
@@ -945,7 +947,7 @@ def upgrade(
                         "--repo",
                         "apache/airflow",
                         "--undo",
-                        head_ref,
+                        branch_name,
                     ],
                     capture_output=True,
                     text=True,
@@ -981,10 +983,15 @@ def upgrade(
                 env=command_env,
             )
             if pr_result.returncode != 0:
-                console_print(f"[error]Failed to create 
PR:\n{pr_result.stdout}\n{pr_result.stderr}[/]")
-                sys.exit(1)
-            pr_url = pr_result.stdout.strip() if pr_result.returncode == 0 
else ""
-            console_print(f"[success]PR created successfully: {pr_url}.[/]")
+                # The branch was already force-pushed, so an existing PR is 
already
+                # up to date — treat a duplicate as success rather than 
failing the run.
+                if "already exists" in pr_result.stderr:
+                    console_print(f"[success]PR already exists for {head_ref}, 
updated with force push.[/]")
+                else:
+                    console_print(f"[error]Failed to create 
PR:\n{pr_result.stdout}\n{pr_result.stderr}[/]")
+                    sys.exit(1)
+            else:
+                console_print(f"[success]PR created successfully: 
{pr_result.stdout.strip()}.[/]")
 
         # Switch back to appropriate branch and delete the temporary branch
         console_print(f"[info]Cleaning up temporary branch 
{branch_name}...[/]")

Reply via email to