Challenge - 5 Problems
SimpleHttpOperator Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of this Airflow task log snippet?
Given this SimpleHttpOperator task in Airflow, what will the log show after a successful GET request?
Apache Airflow
from airflow import DAG from airflow.providers.http.operators.http import SimpleHttpOperator from datetime import datetime with DAG('test_dag', start_date=datetime(2023,1,1), schedule_interval='@once') as dag: task = SimpleHttpOperator( task_id='get_ip', method='GET', http_conn_id='httpbin_default', endpoint='ip' ) # Assume httpbin_default points to https://httpbin.org # The endpoint /ip returns JSON with your IP address
Attempts:
2 left
💡 Hint
The endpoint /ip on httpbin.org returns your IP in JSON format.
✗ Incorrect
The SimpleHttpOperator makes a GET request to https://httpbin.org/ip which returns JSON with the client's IP address under the 'origin' key.
❓ Configuration
intermediate2:00remaining
Which http_conn_id configuration is correct for SimpleHttpOperator?
You want to configure Airflow's connection to call https://api.example.com with token authentication. Which connection setup is correct for http_conn_id?
Attempts:
2 left
💡 Hint
The Host should not include the protocol (https://).
✗ Incorrect
In Airflow connections, the Host field should be the domain without protocol. The authorization header can be passed in the Extra field as JSON.
🔀 Workflow
advanced2:00remaining
What happens if SimpleHttpOperator receives a 500 HTTP response?
In an Airflow DAG, a SimpleHttpOperator task calls an API endpoint that returns HTTP 500 error. What is the expected behavior?
Attempts:
2 left
💡 Hint
HTTP 500 is a server error and SimpleHttpOperator treats non-2xx responses as failures.
✗ Incorrect
SimpleHttpOperator raises an exception on non-2xx HTTP responses, causing the task to fail and trigger retries if configured.
❓ Troubleshoot
advanced2:00remaining
Why does SimpleHttpOperator fail with 'Connection refused' error?
You configured SimpleHttpOperator with http_conn_id pointing to 'my_api'. The task fails with 'Connection refused'. What is the most likely cause?
Attempts:
2 left
💡 Hint
Connection refused means the network connection to the server failed.
✗ Incorrect
Connection refused usually means the host or port is unreachable, often due to wrong host, server down, or firewall blocking.
✅ Best Practice
expert3:00remaining
How to securely pass sensitive API tokens to SimpleHttpOperator?
You need to call a private API with a token using SimpleHttpOperator. What is the best practice to handle the token securely?
Attempts:
2 left
💡 Hint
Airflow Connections are designed to store credentials securely.
✗ Incorrect
Storing tokens in Airflow Connections keeps secrets out of code and allows secure management with Airflow's UI or environment variables.