GitHub user komalrajputtrootech edited a discussion: Task exited with return
code 1 with no errors
Hi all,
### Issue
I’m running a task in an Airflow DAG that calls a Django function. To
initialize Django, I’m using `django.setup()`.
The task consistently fails with **exit code 1**, but no traceback or error
logs are shown.
### What I’ve Observed
* Logs **before** `django.setup()` are printed correctly.
* Logs **after** `django.setup()` never appear.
* The task exits with return code `1` but without any error or stack trace in
Airflow logs.
Here’s the log snippet:
```
[2025-08-25, 07:35:16 UTC] {operators.py:66} INFO - --------------Initializing
django ------------------------------------------
[2025-08-25, 07:35:17 UTC] {local_task_job_runner.py:266} INFO - Task exited
with return code 1
```
### What I Tried
* Enabled `PYTHONFAULTHANDLER` → still no traceback.
* Wrapped `django.setup()` in try/except with `traceback.print_exc()` → nothing
is printed.
* Adjusted Airflow logging to `DEBUG` → no additional output related to the
crash.
* Verified task environment paths and settings are correct.
### Ask
Has anyone encountered a situation where `django.setup()` fails silently inside
an MWAA/Airflow task?
* How can I capture the real traceback?
* Could this be related to how MWAA handles task logging/subprocesses?
---
👉 Do you want me to make this **shorter and more conversational** (like for a
quick GitHub help post), or keep it **detailed and structured** (like a bug
report)?
```
ip-10-192-21-19.us-east-2.compute.internal
*** Reading remote log from Cloudwatch log_group:
airflow-portal-dags-newvpc-Task log_stream:
dag_id=house_armed_services_committee_scraper/run_id=manual__2025-08-26T11_37_53.688039+00_00/task_id=scrap_house_armed_services_committee_data/attempt=1.log.
[2025-08-26, 11:37:57 UTC] {local_task_job_runner.py:123} ▼ Pre task execution
logs
[2025-08-26, 11:37:57 UTC] {taskinstance.py:2613} INFO - Dependencies all met
for dep_context=non-requeueable deps ti=<TaskInstance:
house_armed_services_committee_scraper.scrap_house_armed_services_committee_data
manual__2025-08-26T11:37:53.688039+00:00 [queued]>
[2025-08-26, 11:37:57 UTC] {taskinstance.py:2613} INFO - Dependencies all met
for dep_context=requeueable deps ti=<TaskInstance:
house_armed_services_committee_scraper.scrap_house_armed_services_committee_data
manual__2025-08-26T11:37:53.688039+00:00 [queued]>
[2025-08-26, 11:37:57 UTC] {taskinstance.py:2866} INFO - Starting attempt 1 of 1
[2025-08-26, 11:37:57 UTC] {taskinstance.py:2889} INFO - Executing
<Task(DjangoOperator): scrap_house_armed_services_committee_data> on 2025-08-26
11:37:53.688039+00:00
[2025-08-26, 11:37:57 UTC] {standard_task_runner.py:72} INFO - Started process
2905 to run task
[2025-08-26, 11:37:57 UTC] {standard_task_runner.py:104} INFO - Running:
['airflow', 'tasks', 'run', 'house_armed_services_committee_scraper',
'scrap_house_armed_services_committee_data',
'manual__2025-08-26T11:37:53.688039+00:00', '--job-id', '396', '--raw',
'--subdir', 'DAGS_FOLDER/hsas_dag.py', '--cfg-path', '/tmp/tmpwep4g1sf']
[2025-08-26, 11:37:57 UTC] {standard_task_runner.py:105} INFO - Job 396:
Subtask scrap_house_armed_services_committee_data
[2025-08-26, 11:37:57 UTC] {task_command.py:467} INFO - Running <TaskInstance:
house_armed_services_committee_scraper.scrap_house_armed_services_committee_data
manual__2025-08-26T11:37:53.688039+00:00 [running]> on host
ip-10-192-21-19.us-east-2.compute.internal
[2025-08-26, 11:37:57 UTC] {taskinstance.py:3132} INFO - Exporting env vars:
AIRFLOW_CTX_DAG_OWNER='airflow'
AIRFLOW_CTX_DAG_ID='house_armed_services_committee_scraper'
AIRFLOW_CTX_TASK_ID='scrap_house_armed_services_committee_data'
AIRFLOW_CTX_EXECUTION_DATE='2025-08-26T11:37:53.688039+00:00'
AIRFLOW_CTX_TRY_NUMBER='1'
AIRFLOW_CTX_DAG_RUN_ID='manual__2025-08-26T11:37:53.688039+00:00'
[2025-08-26, 11:37:57 UTC] {operators.py:59} INFO -
******************************************************************************************
[2025-08-26, 11:37:57 UTC] {operators.py:64} INFO -
['/usr/local/airflow/.local/bin', '/python', '/usr/local/lib/python311.zip',
'/usr/local/lib/python3.11', '/usr/local/lib/python3.11/lib-dynload',
'/usr/local/airflow/.local/lib/python3.11/site-packages',
'/usr/local/lib/python3.11/site-packages', '/usr/local/airflow/config',
'/usr/local/airflow/plugins', '/usr/local/airflow/dags',
'/usr/local/airflow/.local/lib/python3.11/site-packages/electo_premium_mwaa']
[2025-08-26, 11:37:57 UTC] {operators.py:65} INFO - {'filters': [], 'name':
'operators', 'level': 0, 'parent': <RootLogger root (INFO)>, 'propagate': True,
'handlers': [], 'disabled': False, '_cache': {20: True}, 'manager':
<logging.Manager object at 0x7f5253fd3dd0>}
[2025-08-26, 11:37:57 UTC] {operators.py:67} INFO -
electo_premium.settings.production
[2025-08-26, 11:37:57 UTC] {operators.py:68} INFO - --------------Initializing
django ------------------------------------------
[2025-08-26, 11:39:58 UTC] {local_task_job_runner.py:266} INFO - Task exited
with return code 1
```
GitHub link: https://github.com/apache/airflow/discussions/54947
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]