stephen-bracken opened a new issue, #68075:
URL: https://github.com/apache/airflow/issues/68075

   ### Under which category would you file this issue?
   
   Airflow Core
   
   ### Apache Airflow version
   
   3.2.0
   
   ### What happened and how to reproduce it?
   
   The scheduler `_enqueue_task_instances_with_queued_state` function raises a 
templating error on the log_filename_template because `ti.logical_date` is not 
set before the log filename. Since I am using s3 buckets as the log backend, I 
am using `ts_nodash` in the log file name instead of `ti.run_id`, because 
standard airflow run ids do not form valid s3 object paths. 
   
   config (using S3 remote logging connection)
   ```
   [logging]
   colored_console_log = False
   dag_processor_log_target = stdout
   delete_local_logs = True
   enable_task_context_logger = True
   encrypt_s3_logs = False
   json_logs = True
   log_filename_template = shared/{{ ti.dag_id }}/{{ ts_nodash | 
default(ti.logical_date.strftime("%%Y%%m%%dT%%H%%M%%S")) }}/{{ ti.task_id 
}}/{%% if ti.map_index >= 0 %%}index_{{ ti.map_index }}/{%% endif %%}attempt_{{ 
try_number | default(ti.try_number) }}.log
   remote_logging = True
   task_log_reader = task
   worker_log_server_port = 8793
   ```
   
   ```
   
{"timestamp":"2026-06-05T12:13:11.047015Z","level":"critical","event":"Unhandled
 
exception","logger":"unhandled_exception","filename":"structlog.py","lineno":689,"exception":[{"exc_type":"UndefinedError","exc_value":"'None'
 has no attribute 
'strftime'","exc_notes":[],"syntax_error":null,"is_cause":false,"frames":[{"filename":"/home/airflow/.local/bin/airflow","lineno":6,"name":"<module>"},{"filename":"/home/airflow/.local/lib/python3.11/site-packages/airflow/__main__.py","lineno":55,"name":"main"},{"filename":"/home/airflow/.local/lib/python3.11/site-packages/airflow/cli/cli_config.py","lineno":49,"name":"command"},{"filename":"/home/airflow/.local/lib/python3.11/site-packages/airflow/utils/cli.py","lineno":113,"name":"wrapper"},{"filename":"/home/airflow/.local/lib/python3.11/site-packages/airflow/utils/providers_configuration_loader.py","lineno":54,"name":"wrapped_function"},{"filename":"/home/airflow/.local/lib/python3.11/site-packages/airflow/cli/commands/scheduler_command.py"
 
,"lineno":66,"name":"scheduler"},{"filename":"/home/airflow/.local/lib/python3.11/site-packages/airflow/cli/commands/daemon_utils.py","lineno":86,"name":"run_command_with_daemon_option"},{"filename":"/home/airflow/.local/lib/python3.11/site-packages/airflow/cli/commands/scheduler_command.py","lineno":69,"name":"<lambda>"},{"filename":"/home/airflow/.local/lib/python3.11/site-packages/airflow/utils/memray_utils.py","lineno":59,"name":"wrapper"},{"filename":"/home/airflow/.local/lib/python3.11/site-packages/airflow/cli/commands/scheduler_command.py","lineno":48,"name":"_run_scheduler_job"},{"filename":"/home/airflow/.local/lib/python3.11/site-packages/airflow/utils/session.py","lineno":100,"name":"wrapper"},{"filename":"/home/airflow/.local/lib/python3.11/site-packages/airflow/jobs/job.py","lineno":355,"name":"run_job"},{"filename":"/home/airflow/.local/lib/python3.11/site-packages/airflow/jobs/job.py","lineno":384,"name":"execute_job"},{"filename":"/home/airflow/.local/lib/python3.11
 
/site-packages/airflow/jobs/scheduler_job_runner.py","lineno":1463,"name":"_execute"},{"filename":"/home/airflow/.local/lib/python3.11/site-packages/airflow/jobs/scheduler_job_runner.py","lineno":1602,"name":"_run_scheduler_loop"},{"filename":"/home/airflow/.local/lib/python3.11/site-packages/airflow/jobs/scheduler_job_runner.py","lineno":1747,"name":"_do_scheduling"},{"filename":"/home/airflow/.local/lib/python3.11/site-packages/airflow/jobs/scheduler_job_runner.py","lineno":1036,"name":"_critical_section_enqueue_task_instances"},{"filename":"/home/airflow/.local/lib/python3.11/site-packages/airflow/jobs/scheduler_job_runner.py","lineno":982,"name":"_enqueue_task_instances_with_queued_state"},{"filename":"/home/airflow/.local/lib/python3.11/site-packages/airflow/executors/workloads/task.py","lineno":94,"name":"make"},{"filename":"/home/airflow/.local/lib/python3.11/site-packages/jinja2/environment.py","lineno":1295,"name":"render"},{"filename":"/home/airflow/.local/lib/python3.11/s
 
ite-packages/jinja2/environment.py","lineno":942,"name":"handle_exception"},{"filename":"<template>","lineno":1,"name":"top-level
 template 
code"},{"filename":"/home/airflow/.local/lib/python3.11/site-packages/jinja2/utils.py","lineno":92,"name":"from_obj"}],"is_group":false,"exceptions":[]}]}
   
{"timestamp":"2026-06-05T12:13:11.047459Z","level":"debug","event":"Disposing 
DB connection pool (PID 
7)","logger":"airflow.settings","filename":"settings.py","lineno":581}
   ```
   
   ### What you think should happen instead?
   
   The `ti.logical_date` (and preferably `ts_nodash`) field needs to be 
populated before the scheduler attempts to create the ti's logfile.
   
   ### Operating System
   
   Debian GNU/Linux 12 (bookworm)
   
   ### Deployment
   
   Other
   
   ### Apache Airflow Provider(s)
   
   amazon
   
   ### Versions of Apache Airflow Providers
   
   apache-airflow-providers-amazon==9.25.0
   apache-airflow-providers-celery==3.18.0
   apache-airflow-providers-common-compat==1.14.3
   apache-airflow-providers-common-io==1.7.2
   apache-airflow-providers-common-messaging==2.0.3
   apache-airflow-providers-common-sql==1.34.0
   apache-airflow-providers-standard==1.12.3
   
   ### Official Helm Chart version
   
   Not Applicable
   
   ### Kubernetes Version
   
   1.33.5
   
   ### Helm Chart configuration
   
   _No response_
   
   ### Docker Image customizations
   
   some additional pip packages for tasks
   
   ### Anything else?
   
   Custom multi team deployment on kubernetes. 
   Occurs on scheduler startup when tasks are enqueued.
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to