You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "rjgoyln (via GitHub)" <gi...@apache.org> on 2026/04/01 14:46:06 UTC

[PR] Incorrect fallback logic [airflow]

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

   
   
   ##### Was generative AI tooling used to co-author this PR?
   
   <!--
   If generative AI tooling has been used in the process of authoring this PR, please
   change below checkbox to `[X]` followed by the name of the tool, uncomment the "Generated-by".
   -->
   
   - [ ] Yes (please specify the tool below)
   
   <!--
   Generated-by: [Tool Name] following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   -->
   
   ---
   
   * Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
   * For fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
   * When adding dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   * For significant user-facing changes create newsfragment: `{pr_number}.significant.rst`, in [airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments). You can add this file in a follow-up commit after the PR is created so you know the PR number.
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Incorrect fallback logic [airflow]

Posted by "bugraoz93 (via GitHub)" <gi...@apache.org>.
bugraoz93 commented on code in PR #64586:
URL: https://github.com/apache/airflow/pull/64586#discussion_r3024072251


##########
airflow-ctl/tests/airflow_ctl/api/test_client.py:
##########
@@ -376,3 +379,16 @@ def test_retry_handling_ok(self):
             response = client.get("http://error")
             assert response.status_code == 200
             assert len(responses) == 1
+
+    def test_debug_mode_missing_debug_creds_reports_correct_error(self, monkeypatch, tmp_path):
+        monkeypatch.setenv("AIRFLOW_HOME", str(tmp_path))
+        monkeypatch.setenv("AIRFLOW_CLI_DEBUG_MODE", "true")
+        monkeypatch.setenv("AIRFLOW_CLI_ENVIRONMENT", "TEST_DEBUG")
+
+        config_path = tmp_path / "TEST_DEBUG.json"
+        config_path.write_text(json.dumps({"api_url": "http://localhost:8080"}), encoding="utf-8")
+        # 不建立 debug_creds_TEST_DEBUG.json,模擬缺檔

Review Comment:
   I would love to understand what is written but I cannot :)
   I would be in favor of either deleting since it is in test and test itself is self explanatory or maybe translating into English to continue with default 
   What do you think?



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Incorrect fallback logic [airflow]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #64586:
URL: https://github.com/apache/airflow/pull/64586#discussion_r3025319720


##########
airflow-ctl/src/airflowctl/api/client.py:
##########
@@ -227,9 +227,17 @@ def load(self) -> Credentials:
                     debug_creds_path = os.path.join(
                         default_config_dir, f"debug_creds_{self.input_cli_config_file}"
                     )
-                    with open(debug_creds_path) as df:
-                        debug_credentials = json.load(df)
-                        self.api_token = debug_credentials.get(f"api_token_{self.api_environment}")
+                    try:
+                        with open(debug_creds_path) as df:
+                            debug_credentials = json.load(df)
+                            self.api_token = debug_credentials.get(f"api_token_{self.api_environment}")
+                    except FileNotFoundError as e:
+                        if self.client_kind == ClientKind.CLI:
+                            raise AirflowCtlCredentialNotFoundException(
+                                f"Debug credentials file not found: {debug_creds_path}. "
+                                "Set AIRFLOW_CLI_DEBUG_MODE=false or login in debug mode first."

Review Comment:
   Minor grammar in the new exception message: “login in debug mode” should be “log in (in) debug mode” (or similar). Since this is user-facing, please adjust the wording for clarity.
   ```suggestion
                                   "Set AIRFLOW_CLI_DEBUG_MODE=false or log in with debug mode enabled first."
   ```



##########
airflow-ctl/tests/airflow_ctl/api/test_client.py:
##########
@@ -376,3 +379,16 @@ def test_retry_handling_ok(self):
             response = client.get("http://error")
             assert response.status_code == 200
             assert len(responses) == 1
+
+    def test_debug_mode_missing_debug_creds_reports_correct_error(self, monkeypatch, tmp_path):
+        monkeypatch.setenv("AIRFLOW_HOME", str(tmp_path))
+        monkeypatch.setenv("AIRFLOW_CLI_DEBUG_MODE", "true")
+        monkeypatch.setenv("AIRFLOW_CLI_ENVIRONMENT", "TEST_DEBUG")
+
+        config_path = tmp_path / "TEST_DEBUG.json"
+        config_path.write_text(json.dumps({"api_url": "http://localhost:8080"}), encoding="utf-8")
+        # 不建立 debug_creds_TEST_DEBUG.json,模擬缺檔

Review Comment:
   The inline comment is not in English. This test module’s existing comments/docstrings are in English, so please rewrite this comment in English to match the repository’s conventions.
   ```suggestion
           # Intentionally do not create debug_creds_TEST_DEBUG.json to simulate a missing file
   ```



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Incorrect fallback logic [airflow]

Posted by "rjgoyln (via GitHub)" <gi...@apache.org>.
rjgoyln commented on code in PR #64586:
URL: https://github.com/apache/airflow/pull/64586#discussion_r3025539548


##########
airflow-ctl/tests/airflow_ctl/api/test_client.py:
##########
@@ -376,3 +379,16 @@ def test_retry_handling_ok(self):
             response = client.get("http://error")
             assert response.status_code == 200
             assert len(responses) == 1
+
+    def test_debug_mode_missing_debug_creds_reports_correct_error(self, monkeypatch, tmp_path):
+        monkeypatch.setenv("AIRFLOW_HOME", str(tmp_path))
+        monkeypatch.setenv("AIRFLOW_CLI_DEBUG_MODE", "true")
+        monkeypatch.setenv("AIRFLOW_CLI_ENVIRONMENT", "TEST_DEBUG")
+
+        config_path = tmp_path / "TEST_DEBUG.json"
+        config_path.write_text(json.dumps({"api_url": "http://localhost:8080"}), encoding="utf-8")
+        # 不建立 debug_creds_TEST_DEBUG.json,模擬缺檔

Review Comment:
   Sorry, I didn’t notice that. Thanks for pointing it out .  I’ll translate it into English.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Incorrect fallback logic [airflow]

Posted by "bugraoz93 (via GitHub)" <gi...@apache.org>.
bugraoz93 merged PR #64586:
URL: https://github.com/apache/airflow/pull/64586


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org