Complete the code to retrieve a secret value using Airflow's Variable API.
from airflow.models import Variable api_key = Variable.get([1])
You must pass the secret name as a string to Variable.get(). Using quotes ensures it is treated as a string key.
Complete the code to set a default value when retrieving a secret that might not exist.
from airflow.models import Variable password = Variable.get('DB_PASSWORD', [1]='default_pass')
The correct parameter to set a default value is default_var with the desired default string.
Fix the error in the code to correctly fetch a secret from Airflow's connection backend.
from airflow.hooks.base import BaseHook conn = BaseHook.get_connection([1]) print(conn.password)
The connection ID must be passed as a string with quotes to get_connection().
Fill both blanks to create a dictionary comprehension that stores secret names and their values from Airflow Variables.
secrets = { [1]: Variable.get([2]) for [1] in secret_names }The variable name used in the loop and as the key must be the same identifier without quotes.
Fill all three blanks to filter Airflow Variables whose values are not empty strings.
filtered_vars = { [1]: Variable.get([2]) for [1] in Variable.get_all() if Variable.get([3]) != '' }The loop variable key is used as the dictionary key, and to get the variable value. It must be without quotes.