Troubleshooting
Common issues and solutions when migrating Airflow DAGs to Prefect flows.
Validation Issues
Syntax Errors in Generated Code
Symptom: validate reports syntax_valid: false.
{
"syntax_valid": false,
"syntax_errors": [
{ "line": 3, "column": 24, "message": "unexpected EOF while parsing" }
]
}
Solutions:
- Check the
syntax_errorsarray for line/column/message details - Fix the generated code and re-validate
- Common causes: missing closing parentheses, unclosed strings, indentation errors
Task Count Differences
Symptom: The generated flow has fewer tasks than the original DAG.
Solutions:
-
Use the
comparison_guidancefromvalidateoutput to check each item:- Are all tasks from the DAG represented in the flow?
- Were DummyOperator/EmptyOperator nodes intentionally removed?
- Were dynamic tasks fully converted?
-
For dynamic tasks, ensure all generated tasks are represented:
# Airflow dynamic tasks for i in range(3): task = PythonOperator(task_id=f"task_{i}", ...) # Prefect equivalent for i in range(3): task_i.submit(...) # Or use .map()
Dependency Ordering
Symptom: Tasks may run in wrong order in the Prefect flow.
Solutions:
-
Ensure explicit data flow between tasks:
# Wrong - no explicit dependency @flow def my_flow(): extract() transform() # May run before extract finishes # Correct - explicit data dependency @flow def my_flow(): data = extract() transform(data) # Waits for extract -
Use
wait_forfor non-data dependencies:from prefect import flow, task @flow def my_flow(): a = task_a.submit() b = task_b.submit(wait_for=[a]) # Explicit ordering
XCom Pattern Not Converted
Symptom: Generated code still references ti.xcom_pull or context['ti'].
Solutions:
-
Replace XCom pull with function parameters:
# Airflow def transform(**context): data = context['ti'].xcom_pull(task_ids='extract') # Prefect @task def transform(data): # Receive as parameter ... @flow def my_flow(): data = extract() transform(data) # Pass directly -
For multi-task pulls, use explicit parameters:
# Airflow data = ti.xcom_pull(task_ids=['task_a', 'task_b']) # Prefect @task def combine(data_a, data_b): ... @flow def my_flow(): a = task_a() b = task_b() combine(a, b)
Use lookup_concept("xcom") for detailed XCom→return-value translation rules.
Tool Issues
read_dag Errors
Symptom: read_dag fails to read a file.
Solutions:
- Ensure the file path is correct and accessible
- Both file paths and inline code are supported — pass code directly via the
contentparameter - Verify the file contains valid Python
lookup_concept Returns No Match
Symptom: lookup_concept doesn't find a translation for your concept.
Solutions:
- Try variations:
PythonOperator,python-operator,python_operatorall work - Check Operator Coverage for supported operators
- Use
search_prefect_docsfor concepts not in the pre-compiled knowledge base - For custom operators, manual conversion is required
search_prefect_docs Not Available
Symptom: search_prefect_docs returns an error or no results.
Solutions:
- Check that
MCP_PREFECT_ENABLEDis not set tofalse - Verify network connectivity to
docs.prefect.io - The tool requires the Prefect MCP server at
https://docs.prefect.io/mcp
Runtime Issues
Import Errors
Symptom: Converted flow fails to import.
Solutions:
-
Install required Prefect integrations:
pip install prefect-aws prefect-gcp prefect-sqlalchemy -
Check for missing custom modules
-
Verify Python version compatibility
Connection/Block Not Found
Symptom: Flow fails looking for Airflow connection.
Solutions:
- Create corresponding Prefect Block — use
lookup_concept("connections")for mapping guidance - Update code to use
Block.load()pattern - See Prefect Cloud Guide for Block examples
Schedule Not Triggering
Symptom: Converted flow doesn't run on schedule.
Solutions:
-
Verify deployment was created:
prefect deployment ls -
Check schedule configuration in prefect.yaml
-
Ensure worker is running:
prefect worker start --pool "my-pool"
Getting Help
If you encounter issues not covered here:
- Check the validation output for syntax errors and comparison guidance
- Use
lookup_conceptandsearch_prefect_docsfor translation guidance - Review the Prefect Cloud guide for deployment patterns
- Open an issue on GitHub with:
- Original DAG (sanitized)
- Generated flow code
- Validation result
- Expected vs actual behavior