You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "alamashir (via GitHub)" <gi...@apache.org> on 2025/11/25 23:46:41 UTC
[PR] Fix Google Cloud Data Fusion hook to handle pipeline start errors properly [airflow]
alamashir opened a new pull request, #58698:
URL: https://github.com/apache/airflow/pull/58698
## Description
Fixes #50387 - Bug in Data Fusion hook where `start_pipeline` crashes with `KeyError: 'runId'` when pipelines fail to start.
## Problem
The hook used the multi-program start endpoint which returns HTTP 200 even on failures. The code accessed `response_json[0]["runId"]` without validation, causing a KeyError when the field was missing.
## Solution
- Switch to single-program start endpoint: `POST .../apps/{app}/{program-type}s/{program-id}/start`
- Validate `runId` exists in response before accessing
- Return clear error messages when pipelines fail to start
## Changes
Updated `start_pipeline` method to use correct CDAP endpoint and added response validation.
## Breaking Changes
None - method signature and return type unchanged. Only the internal API endpoint changed.
## Testing
```bash
pytest providers/google/tests/unit/google/cloud/hooks/test_datafusion.py -v
```
--
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] Fix Google Cloud Data Fusion hook to handle pipeline start errors properly [airflow]
Posted by "alamashir (via GitHub)" <gi...@apache.org>.
alamashir commented on PR #58698:
URL: https://github.com/apache/airflow/pull/58698#issuecomment-3587770631
@VladaZakharova Thank you for the feedback! I've verified the fix works correctly with all 45 unit tests passing, including a new test specifically for the error case (`test_start_pipeline_should_fail_if_no_run_id`).
Running the full system tests requires setting up and provisioning a Data Fusion instance. Given that the unit tests comprehensively cover the fix (switching from multi-program to single-program endpoint + runId validation), I believe they provide sufficient verification. However, if you'd like me to set up and run the full system tests, I'm happy to do so.
--
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] Fix Google Cloud Data Fusion hook to handle pipeline start errors properly [airflow]
Posted by "alamashir (via GitHub)" <gi...@apache.org>.
alamashir commented on PR #58698:
URL: https://github.com/apache/airflow/pull/58698#issuecomment-3591720514
@shahar1 @VladaZakharova if you can, that will be great.
I spent some time setting up CDF session but had some issues and that will need quite some time for me to setup. I can spend more time if needed end of next week. So if i dont hear back from you all by then, i can do it.
--
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] Fix Google Cloud Data Fusion hook to handle pipeline start errors properly [airflow]
Posted by "dabla (via GitHub)" <gi...@apache.org>.
dabla commented on code in PR #58698:
URL: https://github.com/apache/airflow/pull/58698#discussion_r2563578830
##########
providers/google/tests/unit/google/cloud/hooks/test_datafusion.py:
##########
@@ -340,42 +340,34 @@ def test_list_pipelines_should_fail_if_status_not_200(self, mock_request, hook):
@mock.patch(HOOK_STR.format("DataFusionHook._cdap_request"))
def test_start_pipeline(self, mock_request, hook):
run_id = 1234
- mock_request.return_value = mock.MagicMock(status=200, data=f'[{{"runId":{run_id}}}]')
+ mock_request.return_value = mock.MagicMock(status=200, data=f'{{"runId":{run_id}}}')
Review Comment:
Great PR, love the way how you refactored it. Just one little improvement which wouldn't hurt is to spec the MagicMock with google.auth.transport.requests.Request, that way static checks can see if mocked methods actually exists for that class.
##########
providers/google/tests/unit/google/cloud/hooks/test_datafusion.py:
##########
@@ -409,16 +395,29 @@ def test_start_pipeline_should_fail_if_status_not_200(self, mock_request, hook):
hook.start_pipeline(
pipeline_name=PIPELINE_NAME, instance_url=INSTANCE_URL, runtime_args=RUNTIME_ARGS
)
- body = [
- {
- "appId": PIPELINE_NAME,
- "programType": "workflow",
- "programId": "DataPipelineWorkflow",
- "runtimeargs": RUNTIME_ARGS,
- }
- ]
mock_request.assert_called_once_with(
- url=f"{INSTANCE_URL}/v3/namespaces/default/start", method="POST", body=body
+ url=f"{INSTANCE_URL}/v3/namespaces/default/apps/{PIPELINE_NAME}/workflows/DataPipelineWorkflow/start",
+ method="POST",
+ body=RUNTIME_ARGS,
+ )
+
+ @mock.patch(HOOK_STR.format("DataFusionHook._cdap_request"))
+ def test_start_pipeline_should_fail_if_no_run_id(self, mock_request, hook):
+ """Test that start_pipeline fails gracefully when response doesn't contain runId."""
+ error_response = '{"error": "Invalid runtime arguments"}'
+ mock_request.return_value = mock.MagicMock(status=200, data=error_response)
Review Comment:
Same here.
--
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] Fix Google Cloud Data Fusion hook to handle pipeline start errors properly [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #58698:
URL: https://github.com/apache/airflow/pull/58698
--
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] Fix Google Cloud Data Fusion hook to handle pipeline start errors properly [airflow]
Posted by "VladaZakharova (via GitHub)" <gi...@apache.org>.
VladaZakharova commented on PR #58698:
URL: https://github.com/apache/airflow/pull/58698#issuecomment-3580701716
hi there! thank you for the fix. Can please also provide the screenshot of the green system tests running in Airflow UI?
--
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] Fix Google Cloud Data Fusion hook to handle pipeline start errors properly [airflow]
Posted by "shahar1 (via GitHub)" <gi...@apache.org>.
shahar1 commented on PR #58698:
URL: https://github.com/apache/airflow/pull/58698#issuecomment-3591717019
> owever, if you'd like me to set up and run the full system tests, I'm happy to do so.
> @VladaZakharova Thank you for the feedback! I've verified the fix works correctly with all 45 unit tests passing, including a new test specifically for the error case (`test_start_pipeline_should_fail_if_no_run_id`).
>
> Running the full system tests requires setting up and provisioning a Data Fusion instance. Given that the unit tests comprehensively cover the fix (switching from multi-program to single-program endpoint + runId validation), I believe they provide sufficient verification. However, if you'd like me to set up and run the full system tests, I'm happy to do so.
If you're able to run the system tests on your side and provide some screenshots, we'll be happy if you could do so.
If not, please let us know - I believe that Vlada's team could figure out a solution for that.
--
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