This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 245e9a33855 fix conf.getint logic to handling float type value from
airflow.cfg (#60925)
245e9a33855 is described below
commit 245e9a3385529cd667815aa1099db6271a53d5a7
Author: Jeongwoo Do <[email protected]>
AuthorDate: Thu Jan 22 23:29:42 2026 +0900
fix conf.getint logic to handling float type value from airflow.cfg (#60925)
---
.../src/airflow_shared/configuration/parser.py | 13 +++++++++----
.../configuration/tests/configuration/test_parser.py | 18 ++++++++++++++++++
2 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/shared/configuration/src/airflow_shared/configuration/parser.py
b/shared/configuration/src/airflow_shared/configuration/parser.py
index a05c13174ae..8868f7d7800 100644
--- a/shared/configuration/src/airflow_shared/configuration/parser.py
+++ b/shared/configuration/src/airflow_shared/configuration/parser.py
@@ -1050,10 +1050,15 @@ class AirflowConfigParser(ConfigParser):
try:
return int(val)
except ValueError:
- raise AirflowConfigException(
- f'Failed to convert value to int. Please check "{key}" key in
"{section}" section. '
- f'Current value: "{val}".'
- )
+ try:
+ if (float_val := float(val)) != (int_val := int(float_val)):
+ raise ValueError
+ return int_val
+ except (ValueError, OverflowError):
+ raise AirflowConfigException(
+ f'Failed to convert value to int. Please check "{key}" key
in "{section}" section. '
+ f'Current value: "{val}".'
+ )
def getfloat(self, section: str, key: str, **kwargs) -> float: # type:
ignore[override]
"""Get config value as float."""
diff --git a/shared/configuration/tests/configuration/test_parser.py
b/shared/configuration/tests/configuration/test_parser.py
index e76ce1085d2..484e6373f0e 100644
--- a/shared/configuration/tests/configuration/test_parser.py
+++ b/shared/configuration/tests/configuration/test_parser.py
@@ -117,6 +117,12 @@ key1 = str
[valid]
key2 = 1
+
+[float]
+key3 = 4.096e+07
+
+[decimal]
+key4 = 12.34
"""
test_conf = AirflowConfigParser(default_config=test_config)
with pytest.raises(
@@ -130,6 +136,18 @@ key2 = 1
assert isinstance(test_conf.getint("valid", "key2"), int)
assert test_conf.getint("valid", "key2") == 1
+ assert isinstance(test_conf.getint("float", "key3"), int)
+ assert test_conf.getint("float", "key3") == 40960000
+
+ with pytest.raises(
+ AirflowConfigException,
+ match=re.escape(
+ 'Failed to convert value to int. Please check "key4" key in
"decimal" section. '
+ 'Current value: "12.34".'
+ ),
+ ):
+ test_conf.getint("decimal", "key4")
+
def test_getfloat(self):
"""Test AirflowConfigParser.getfloat"""
test_config = """