Repository navigation
Description
Apache Airflow version
Other Airflow 2 version (please specify below)
If "Other Airflow 2 version" selected, which one?
2.10.4
What happened?
What happened:
When using a custom schema for the Airflow metadata database, the log_template table is not automatically seeded with default data. As a result, when triggering a DAG, Airflow attempts to set the log_template_id using the following code:
run.log_template_id = int(session.scalar(select(func.max(LogTemplate.table.c.id))))
Because the custom schema’s log_template table is empty, the query returns None, and attempting to convert None to an integer raises a TypeError:
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'
In contrast, when using the default public schema, the table is seeded with default data, and this error does not occur.
What you think should happen instead?
The log_template table should be seeded with default data even when using a custom schema—just as it is for the public schema. Alternatively, the code should handle an empty log_template table gracefully (for example, by defaulting to 0 when no rows exist).
How to reproduce
Create a custom schema in your Airflow metadata database (e.g., my_custom_schema).
Update the Airflow configuration (in airflow.cfg or via the environment variable sql_alchemy_schema = ${SQL_ALCHEMY_SCHEMA}
to use your custom schema.
- Start Airflow.
- Run db migrate ( this will add permisssions and tables inside the schema)
- Trigger a DAG via the UI or API.
- Observe that the DAG trigger fails with the following error:
- TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'
because the log_template table in the custom schema is empty.
Operating System
docker container- aws ecs
Versions of Apache Airflow Providers
2.10.4 ( docker image)
Deployment
Other Docker-based deployment
Deployment details
we used the offciail docker image from airflow and on top of that we run few commands and deploy it in aws ecs service
Anything else?
No response
Are you willing to submit PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct

Activity
boring-cyborg commentedon Mar 3, 2025
Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.
amolsr commentedon Mar 3, 2025
hi, please assign this issue to me.
amolsr commentedon Mar 3, 2025
If you are running airflow db migrate. this would automatically create 2 entries in the table as shown in image. If you can provide more info on the setup, I would be able to help you better.
arvindmunna commentedon Mar 4, 2025
Hi @amolsr
This happened with AWS RDS Postgres db version 15, we launched a micro db in postgres and tried running the db migrate and It did created the tables and default entries under Public schema, but we need a custom schema, so we created the custom schema and modified the airflow.cfg file sql_alchemy_schema and then re ran the db migrate to my remote postgres, this time it created the tables and permissions but there is no default values created in LogTemplate_id table. So this throws error when we trigger the dag even the example dags will fail.
Solution : we ran a sql query manually to add some data in that empty LogTemplate_id table and this fixed the error.
Note : This might be running ok with local dB's please try with the same setup I have told.
arvindmunna commentedon Mar 5, 2025
Any update on this @amolsr
amolsr commentedon Mar 5, 2025
Please share the DB permission for the user you are using.
arvindmunna commentedon Mar 5, 2025
I might not have permission to share those creds for db.
amolsr commentedon Mar 5, 2025
I’m not referring to credentials but to db user permissions. I wanted to verify whether your db user has the necessary permissions to perform insert operations on the schema you created. In some cases, db users are granted permissions for DDL operations but not for DML operations.
arvindmunna commentedon Mar 5, 2025
we used the default user and the user was the owner of the schema and the user has all permissions over the schema.
amolsr commentedon Mar 6, 2025
Can you share your database logs file for looking further? It feels like i have incomplete information to actually debug on the issue.
FranciscoRuiz04 commentedon Nov 7, 2025
Maybe you already fixed your issue @arvindmunna but this could help somebody else with the same problem.
I'm running Airflow 3.1.0 with PostgreSQL version 16 as backend. What I found is that when you execute
airflow db migratewith a custom schema other than public, Airflow does indeed use the schema name defined inAIRFLOW__DATABASE__SQL_ALCHEMY_SCHEMAto create all the tables it needs. However, when it tries to seed up thelog_templatetable Airflow does not take into account the schema defined; that is, uses the default search path (public schema) instead. So, one possible solution is passing explicitly the search path value inside the URI like this:AIRFLOW__DATABASE__SQL_ALCHEMY_CONN=postgresql+psychoph2:user:password@host:port/db?options=-csearch_path%3Dschemaf-necas commentedon Dec 3, 2025
@FranciscoRuiz04 you saved my life