Skip to content

Fix exception when logging stdout with a custom %-fmt string.#58959

Merged
ashb merged 1 commit intoapache:mainfrom
astronomer:custom-percent-log-fmt-error-handling
Dec 2, 2025
Merged

Fix exception when logging stdout with a custom %-fmt string.#58959
ashb merged 1 commit intoapache:mainfrom
astronomer:custom-percent-log-fmt-error-handling

Conversation

@ashb
Copy link
Copy Markdown
Member

@ashb ashb commented Dec 2, 2025

For instance, if you set this config

[logging]
log_format={%%(filename)s:%%(lineno)d} --- %%(message)s

this would blow up with an error like this on printing anything from a
trigger, killing the triggerer process:

2025-11-03 14:13:27   File "/usr/local/lib/python3.12/site-packages/airflow/_shared/logging/percent_formatter.py", line 149, in __call__
2025-11-03 14:13:27     sio.write(self._fmt % params)
2025-11-03 14:13:27               ~~~~~~~~~~^~~~~~~~
2025-11-03 14:13:27 TypeError: %d format: a real number is required, not NoneType

^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

For instance, if you set this config

```ini
[logging]
log_format={%%(filename)s:%%(lineno)d} --- %%(message)s
```

this would blow up with an error like this on printing anything from a
trigger, killing the triggerer process:

```
2025-11-03 14:13:27   File "/usr/local/lib/python3.12/site-packages/airflow/_shared/logging/percent_formatter.py", line 149, in __call__
2025-11-03 14:13:27     sio.write(self._fmt % params)
2025-11-03 14:13:27               ~~~~~~~~~~^~~~~~~~
2025-11-03 14:13:27 TypeError: %d format: a real number is required, not NoneType
```
Copy link
Copy Markdown
Contributor

@amoghrajesh amoghrajesh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch

@ashb ashb merged commit 586fe93 into apache:main Dec 2, 2025
57 checks passed
@ashb ashb deleted the custom-percent-log-fmt-error-handling branch December 2, 2025 17:50
github-actions bot pushed a commit that referenced this pull request Dec 2, 2025
…ing. (#58959)

For instance, if you set this config

```ini
[logging]
log_format={%%(filename)s:%%(lineno)d} --- %%(message)s
```

this would blow up with an error like this on printing anything from a
trigger, killing the triggerer process:

```
2025-11-03 14:13:27   File "/usr/local/lib/python3.12/site-packages/airflow/_shared/logging/percent_formatter.py", line 149, in __call__
2025-11-03 14:13:27     sio.write(self._fmt % params)
2025-11-03 14:13:27               ~~~~~~~~~~^~~~~~~~
2025-11-03 14:13:27 TypeError: %d format: a real number is required, not NoneType
```
(cherry picked from commit 586fe93)

Co-authored-by: Ash Berlin-Taylor <ash@apache.org>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 2, 2025

Backport successfully created: v3-1-test

Status Branch Result
v3-1-test PR Link

github-actions bot pushed a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Dec 2, 2025
…ing. (apache#58959)

For instance, if you set this config

```ini
[logging]
log_format={%%(filename)s:%%(lineno)d} --- %%(message)s
```

this would blow up with an error like this on printing anything from a
trigger, killing the triggerer process:

```
2025-11-03 14:13:27   File "/usr/local/lib/python3.12/site-packages/airflow/_shared/logging/percent_formatter.py", line 149, in __call__
2025-11-03 14:13:27     sio.write(self._fmt % params)
2025-11-03 14:13:27               ~~~~~~~~~~^~~~~~~~
2025-11-03 14:13:27 TypeError: %d format: a real number is required, not NoneType
```
(cherry picked from commit 586fe93)

Co-authored-by: Ash Berlin-Taylor <ash@apache.org>
@ashb ashb added this to the Airflow 3.1.4 milestone Dec 2, 2025
RoyLee1224 pushed a commit to RoyLee1224/airflow that referenced this pull request Dec 3, 2025
…#58959)

For instance, if you set this config

```ini
[logging]
log_format={%%(filename)s:%%(lineno)d} --- %%(message)s
```

this would blow up with an error like this on printing anything from a
trigger, killing the triggerer process:

```
2025-11-03 14:13:27   File "/usr/local/lib/python3.12/site-packages/airflow/_shared/logging/percent_formatter.py", line 149, in __call__
2025-11-03 14:13:27     sio.write(self._fmt % params)
2025-11-03 14:13:27               ~~~~~~~~~~^~~~~~~~
2025-11-03 14:13:27 TypeError: %d format: a real number is required, not NoneType
```
itayweb pushed a commit to itayweb/airflow that referenced this pull request Dec 6, 2025
…#58959)

For instance, if you set this config

```ini
[logging]
log_format={%%(filename)s:%%(lineno)d} --- %%(message)s
```

this would blow up with an error like this on printing anything from a
trigger, killing the triggerer process:

```
2025-11-03 14:13:27   File "/usr/local/lib/python3.12/site-packages/airflow/_shared/logging/percent_formatter.py", line 149, in __call__
2025-11-03 14:13:27     sio.write(self._fmt % params)
2025-11-03 14:13:27               ~~~~~~~~~~^~~~~~~~
2025-11-03 14:13:27 TypeError: %d format: a real number is required, not NoneType
```
Subham-KRLX pushed a commit to Subham-KRLX/airflow that referenced this pull request Mar 4, 2026
…#58959)

For instance, if you set this config

```ini
[logging]
log_format={%%(filename)s:%%(lineno)d} --- %%(message)s
```

this would blow up with an error like this on printing anything from a
trigger, killing the triggerer process:

```
2025-11-03 14:13:27   File "/usr/local/lib/python3.12/site-packages/airflow/_shared/logging/percent_formatter.py", line 149, in __call__
2025-11-03 14:13:27     sio.write(self._fmt % params)
2025-11-03 14:13:27               ~~~~~~~~~~^~~~~~~~
2025-11-03 14:13:27 TypeError: %d format: a real number is required, not NoneType
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants