You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "kadubhumika (via GitHub)" <gi...@apache.org> on 2026/10/02 14:25:57 UTC
[PR] Fix DagRun.conf exponent-form float handling in PostgreSQL JSONB [airflow]
kadubhumika opened a new pull request, #74093:
URL: https://github.com/apache/airflow/pull/74093
## Summary
PostgreSQL JSONB can change large exponent-form floating-point values in `DagRun.conf` into large integers when Airflow reads them back.
For example, `1.7E308` can be returned as a Python `int` instead of a `float`.
This PR:
- Adds a custom JSON type for `DagRun.conf` to preserve exponent-form floats.
- Restores these values as Python `float` when reading them back.
- Keeps normal floats, integers, strings, booleans, and nested values unchanged.
- Adds regression tests for large floats and other JSON value types.
## Testing
- Focused regression test: passed
- Ruff: passed
- `git diff --check`: passed
- PostgreSQL JSONB behavior reproduced independently.
The full test file has 3 unrelated local environment failures caused by `airflow_shared` import errors. An additional local PostgreSQL end-to-end test was blocked by local `pg_hba.conf` access configuration.
Closes #74023
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix DagRun.conf exponent-form float handling in PostgreSQL JSONB [airflow]
Posted by "kadubhumika (via GitHub)" <gi...@apache.org>.
kadubhumika commented on code in PR #74093:
URL: https://github.com/apache/airflow/pull/74093#discussion_r4178548305
##########
airflow-core/src/airflow/utils/sqlalchemy.py:
##########
@@ -291,6 +291,73 @@ def load_dialect_impl(self, dialect):
return super().load_dialect_impl(dialect)
+class DagRunConfJSON(TypeDecorator):
Review Comment:
Thanks @ashb, you're right. The failure isn't in storage: Postgres JSONB keeps the
value as a huge numeric, which Python reads back as an int, and msgspec then raises
OverflowError because it can't encode integers outside the 64-bit range.
I'll drop DagRunConfJSON and the DagRun model change, and instead convert any int
outside the int64/uint64 range to a float right before the msgpack encoding. I'll
keep it scoped to the conf payload, handle nested dicts/lists, and leave normal ints
and bools untouched.
I'll also remove the unrelated zip-inflation commit from this branch and rebase on main.
One question: some ints (e.g. 400+ digits) are too large to fit in a float at all.
For those, would you prefer we raise a clear error, or convert to inf? I'd lean
toward raising a clear error, since inf isn't valid JSON.
I'll push the revised approach shortly.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix DagRun.conf exponent-form float handling in PostgreSQL JSONB [airflow]
Posted by "kadubhumika (via GitHub) via commits" <co...@airflow.apache.org>.
kadubhumika commented on PR #74093:
URL: https://github.com/apache/airflow/pull/74093#issuecomment-6692229948
@ashb @eladkal please do check my pr please if there are any changes do tell me i will chnage it.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix DagRun.conf exponent-form float handling in PostgreSQL JSONB [airflow]
Posted by "kadubhumika (via GitHub)" <gi...@apache.org>.
kadubhumika commented on code in PR #74093:
URL: https://github.com/apache/airflow/pull/74093#discussion_r4178548305
##########
airflow-core/src/airflow/utils/sqlalchemy.py:
##########
@@ -291,6 +291,73 @@ def load_dialect_impl(self, dialect):
return super().load_dialect_impl(dialect)
+class DagRunConfJSON(TypeDecorator):
Review Comment:
Hi @ashb , I checked the downstream behavior.
1.7e308 can become a 309-digit Python int after the PostgreSQL JSONB round-trip, and msgspec.msgpack.encode() raises OverflowError for that value.
I also found that #73783 addresses the MessagePack overflow for large integers, but it does not restore the original float type after the JSONB round-trip.
I’ll now trace the Airflow encoding path to see whether converting oversized integers to floats before MessagePack is sufficient and safe, rather than changing the JSONB storage layer.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix DagRun.conf exponent-form float handling in PostgreSQL JSONB [airflow]
Posted by "kadubhumika (via GitHub)" <gi...@apache.org>.
kadubhumika commented on PR #74093:
URL: https://github.com/apache/airflow/pull/74093#issuecomment-5965727427
@eladkal Hi! Quick update on the PR I’ve addressed the two CI issues that came up:
Fixed the MySQL Core test failure by making the regression test compatible with MySQL’s handling of very large integers.
Fixed the static-check/formatting issues reported by CI.
The affected regression test now passes locally, and Ruff + git diff --check are clean.
Whenever you have time, could you please review the PR again? If you notice any other issues or bugs during review, I’ll be happy to address them. Thanks for your time! 🙏
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix DagRun.conf exponent-form float handling in PostgreSQL JSONB [airflow]
Posted by "kadubhumika (via GitHub)" <gi...@apache.org>.
kadubhumika commented on code in PR #74093:
URL: https://github.com/apache/airflow/pull/74093#discussion_r4178548305
##########
airflow-core/src/airflow/utils/sqlalchemy.py:
##########
@@ -291,6 +291,73 @@ def load_dialect_impl(self, dialect):
return super().load_dialect_impl(dialect)
+class DagRunConfJSON(TypeDecorator):
Review Comment:
Thanks @ashb Yes, that makes sense. Thanks for pointing out the design issue I was fixing this at the PostgreSQL/JSONB storage layer, while the actual failure happens later during MessagePack encoding.
I verified that 1.7e308 can become a huge Python int, and msgspec.msgpack.encode() raises an OverflowError for integers outside its supported range.
I’ll rework the PR to handle this at the encoding boundary instead, and I’ll investigate the appropriate way to convert oversized integer values to float before MessagePack serialization.
I’ll update the implementation and regression tests accordingly. I’ll keep this PR open and push the revised approach.
Thanks for pointing me in the right direction! Dont close pr
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix DagRun.conf exponent-form float handling in PostgreSQL JSONB [airflow]
Posted by "kadubhumika (via GitHub)" <gi...@apache.org>.
kadubhumika commented on code in PR #74093:
URL: https://github.com/apache/airflow/pull/74093#discussion_r4178660803
##########
airflow-core/src/airflow/utils/sqlalchemy.py:
##########
@@ -291,6 +291,73 @@ def load_dialect_impl(self, dialect):
return super().load_dialect_impl(dialect)
+class DagRunConfJSON(TypeDecorator):
Review Comment:
I need one day i will solve fix inspect this part thoroughly.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix DagRun.conf exponent-form float handling in PostgreSQL JSONB [airflow]
Posted by "kadubhumika (via GitHub)" <gi...@apache.org>.
kadubhumika commented on code in PR #74093:
URL: https://github.com/apache/airflow/pull/74093#discussion_r4192270099
##########
airflow-core/src/airflow/utils/sqlalchemy.py:
##########
@@ -291,6 +291,73 @@ def load_dialect_impl(self, dialect):
return super().load_dialect_impl(dialect)
+class DagRunConfJSON(TypeDecorator):
Review Comment:
@ashb how would you like to proceed? Are you closing this PR for now, or is there a specific way you'd like me to update it ?
I'm completely happy to follow your lead.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix DagRun.conf exponent-form float handling in PostgreSQL JSONB [airflow]
Posted by "kadubhumika (via GitHub)" <gi...@apache.org>.
kadubhumika commented on code in PR #74093:
URL: https://github.com/apache/airflow/pull/74093#discussion_r4181421464
##########
airflow-core/src/airflow/utils/sqlalchemy.py:
##########
@@ -291,6 +291,73 @@ def load_dialect_impl(self, dialect):
return super().load_dialect_impl(dialect)
+class DagRunConfJSON(TypeDecorator):
Review Comment:
Thanks @ashb Sir, I traced the full path through _FrameMixin.as_bytes()
and also inspected #73783.
I see that #73783 already addresses the MessagePack OverflowError
by preserving oversized integers through a MessagePack extension.
The remaining difference is the separate float → int conversion caused
by the PostgreSQL JSONB round trip. For example, 1.7E308 is a float
before persistence but becomes a 309-digit int after reading it back.
So I understand now that the encoding crash and the numeric-type
preservation are separate issues. Before changing the implementation,
I'd like to confirm whether Airflow 3 is expected to preserve the
original float type here, or whether #73783's exact-int behavior is
the intended semantics. Sorry Next time before working on any issues or prs i will first t inspect all existing's prs on it.. Thank you .. I learned a lott..
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix DagRun.conf exponent-form float handling in PostgreSQL JSONB [airflow]
Posted by "kadubhumika (via GitHub)" <gi...@apache.org>.
kadubhumika commented on code in PR #74093:
URL: https://github.com/apache/airflow/pull/74093#discussion_r4181421464
##########
airflow-core/src/airflow/utils/sqlalchemy.py:
##########
@@ -291,6 +291,73 @@ def load_dialect_impl(self, dialect):
return super().load_dialect_impl(dialect)
+class DagRunConfJSON(TypeDecorator):
Review Comment:
Thanks @ashb I traced the full path through _FrameMixin.as_bytes()
and also inspected #73783.
I see that #73783 already addresses the MessagePack OverflowError
by preserving oversized integers through a MessagePack extension.
The remaining difference is the separate float → int conversion caused
by the PostgreSQL JSONB round trip. For example, 1.7E308 is a float
before persistence but becomes a 309-digit int after reading it back.
So I understand now that the encoding crash and the numeric-type
preservation are separate issues. Before changing the implementation,
I'd like to confirm whether Airflow 3 is expected to preserve the
original float type here, or whether #73783's exact-int behavior is
the intended semantics. Sorry Next time before working on any issues or prs i will first t inspect all existing's prs on it.. Thank you .. I learned a lott..
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix DagRun.conf exponent-form float handling in PostgreSQL JSONB [airflow]
Posted by "ashb (via GitHub)" <gi...@apache.org>.
ashb commented on code in PR #74093:
URL: https://github.com/apache/airflow/pull/74093#discussion_r4178523792
##########
airflow-core/src/airflow/utils/sqlalchemy.py:
##########
@@ -291,6 +291,73 @@ def load_dialect_impl(self, dialect):
return super().load_dialect_impl(dialect)
+class DagRunConfJSON(TypeDecorator):
Review Comment:
Do we need to this? Is there not an option to instead make anything larger than 64bit it force to float before we send to msgspec.
In other words, this isn't a storage or JSON vs JSONB issue, it's an encoding issue.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix DagRun.conf exponent-form float handling in PostgreSQL JSONB [airflow]
Posted by "kadubhumika (via GitHub)" <gi...@apache.org>.
kadubhumika commented on code in PR #74093:
URL: https://github.com/apache/airflow/pull/74093#discussion_r4178548305
##########
airflow-core/src/airflow/utils/sqlalchemy.py:
##########
@@ -291,6 +291,73 @@ def load_dialect_impl(self, dialect):
return super().load_dialect_impl(dialect)
+class DagRunConfJSON(TypeDecorator):
Review Comment:
Thanks @ashb , you're right. The failure isn't in storage: Postgres JSONB keeps the
value as a huge numeric, which Python reads back as an int, and msgspec then raises
OverflowError because it can't encode integers outside the 64-bit range.
I'll drop DagRunConfJSON and the DagRun model change, and instead convert any int
outside the int64/uint64 range to a float right before the msgpack encoding. I'll
keep it scoped to the conf payload, handle nested dicts/lists, and leave normal ints
and bools untouched.
I'll also remove the unrelated zip-inflation commit from this branch and rebase on main.
One question: some ints (e.g. 400+ digits) are too large to fit in a float at all.
For those, would you prefer we raise a clear error, or convert to inf? I'd lean
toward raising a clear error, since inf isn't valid JSON.
I'll push the revised approach shortly.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org