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

potiuk pushed a commit to branch v3-2-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v3-2-test by this push:
     new 02f5c137477 [v3-2-test] Fix E2E Flaky Tests Report failing with gh api 
404 (#65120) (#65157)
02f5c137477 is described below

commit 02f5c1374771243057f3c2c44553d87a3a5bffd6
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Mon Apr 13 18:08:38 2026 +0200

    [v3-2-test] Fix E2E Flaky Tests Report failing with gh api 404 (#65120) 
(#65157)
    
    scripts/ci/analyze_e2e_flaky_tests.py builds 'gh api <endpoint> -f
    key=val ...' to list workflow runs. The gh CLI defaults to POST
    whenever -f parameters are present, so the workflow runs endpoint
    returned 'Not Found (HTTP 404)' and the script wrote no output file,
    causing the downstream slack-github-action step to crash with ENOENT
    on slack-message.json.
    
    Force --method GET in the gh_api helper and add a regression test.
    (cherry picked from commit 7ae29fb783593e6ec1f25a8864bd25b26c172670)
    
    Co-authored-by: Jarek Potiuk <[email protected]>
---
 scripts/ci/analyze_e2e_flaky_tests.py            |  9 +++++++--
 scripts/tests/ci/test_analyze_e2e_flaky_tests.py | 13 +++++++++++++
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/scripts/ci/analyze_e2e_flaky_tests.py 
b/scripts/ci/analyze_e2e_flaky_tests.py
index bf5aef53ffa..c56fb7e48eb 100755
--- a/scripts/ci/analyze_e2e_flaky_tests.py
+++ b/scripts/ci/analyze_e2e_flaky_tests.py
@@ -65,8 +65,13 @@ def escape_slack_mrkdwn(text: str) -> str:
 
 
 def gh_api(endpoint: str, **kwargs: str) -> str | None:
-    """Call GitHub API via gh CLI."""
-    cmd = ["gh", "api", endpoint]
+    """Call GitHub API via gh CLI.
+
+    Forces ``--method GET``: ``gh api`` defaults to POST whenever ``-f``
+    parameters are present, which makes read-only endpoints (such as the
+    workflow runs list) return 404.
+    """
+    cmd = ["gh", "api", "--method", "GET", endpoint]
     for key, value in kwargs.items():
         cmd.extend(["-f", f"{key}={value}"])
     result = subprocess.run(cmd, capture_output=True, text=True, check=False)
diff --git a/scripts/tests/ci/test_analyze_e2e_flaky_tests.py 
b/scripts/tests/ci/test_analyze_e2e_flaky_tests.py
index ff7097c7aee..fcd56d15ada 100644
--- a/scripts/tests/ci/test_analyze_e2e_flaky_tests.py
+++ b/scripts/tests/ci/test_analyze_e2e_flaky_tests.py
@@ -17,8 +17,10 @@
 from __future__ import annotations
 
 import importlib.util
+import subprocess
 import sys
 from pathlib import Path
+from unittest.mock import patch
 
 import pytest
 
@@ -37,6 +39,17 @@ def analyze_module():
     return module
 
 
+class TestGhApi:
+    def test_forces_get_method(self, analyze_module):
+        """`gh api` defaults to POST when -f is passed; we must force GET to 
avoid 404."""
+        completed = subprocess.CompletedProcess(args=[], returncode=0, 
stdout="{}", stderr="")
+        with patch.object(subprocess, "run", return_value=completed) as 
mock_run:
+            
analyze_module.gh_api("repos/apache/airflow/actions/workflows/x/runs", 
branch="main")
+        args = mock_run.call_args[0][0]
+        assert "--method" in args
+        assert args[args.index("--method") + 1] == "GET"
+
+
 class TestEscapeSlackMrkdwn:
     def test_escapes_ampersand(self, analyze_module):
         assert analyze_module.escape_slack_mrkdwn("a & b") == "a &amp; b"

Reply via email to