-
Notifications
You must be signed in to change notification settings - Fork 14.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What's the purpose of the response_check parameter in HttpOperator? #45237
Comments
set
|
Thanks didn’t know that. Wouldn’t it be more logical that when you pass a custom_response check the hook doesn’t chech the response? Now this is confusing imho |
Just tested it and it fails with following error as it considers the check_response passed in the extra_options as a HTTP header:
Will do a PR to fix this. |
Just dropping some thoughts - I agree with the OP that this is unclear and confusing. It looks like There's a lot of leaky API between the One simple way around this particular issue might be to have the HttpOperator take an optional argument like A more fluent alternative might be to have the Operator take a |
Completely agree with this detailed elaboration. I would suggest that when a custom check_response callback is specified within the operator, it would then in turn be passed through the HttpHook run method so that it doesn’t use the default check_status. Also specifying the check_response in the extra options didn’t work and only makes the useage overly complicated for nothing. |
What exactly was your code here? Did you put the Edit: I ask bc I played with the tests and the only way I could get that InvalidHeader error was to pass the |
I've defined those in the extra_options of the connection, tested on the latest Airflow version. |
The issue is in this method, it pops all non related extra_options parameters and keeps the rest to pass it as headers, an extra pop should be needed on the check_response key to avoid the issue, I'll open a PR to fix that:
|
Apache Airflow version
2.10.4
If "Other Airflow 2 version" selected, which one?
No response
What happened?
I wanted to raise an AirflowSkipException if a HTTP 404 is returned by a REST endpoint if the requested resource isn't found
What you think should happen instead?
I would have expected the custom response_check code being invoked, but it isn't, as the response status_code is already checked within the check_response method of the HttpHook. There, when the status_code isn't within the 2x or 3x range, an AirflowException is being raised, thus making the possibility to check the response yourself through a custom response_check obsolete, as the code will never be invoked. A possible solution would be to pass the custom response_check defined int the operator to the HttpHook, that way the same logic would be applied.
How to reproduce
Just define a custom response_check which ignores a 404 and run the HttpOperator for a non existing resource which will return a 404, you'll see that the custom response_check will never be invoked and the task will fail.
Operating System
RedHat
Versions of Apache Airflow Providers
apache-airflow-providers-http 5.0.0
Deployment
Docker-Compose
Deployment details
No response
Anything else?
No response
Are you willing to submit PR?
Code of Conduct
The text was updated successfully, but these errors were encountered: