Repository navigation
Fix the %% escape in the access log format - #14391
ArnabDutta01 wants to merge 3 commits into
Conversation
A literal "%%" in the access log format was not treated as an escape: the cleanup step turned it into "%%%", so every log line failed with "Error in logging". The "%" that followed it was also taken as the start of an atom, so "%%P" logged the process id instead of "%P". Split the format on "%%" before looking up atoms and join the compiled parts back with "%%". Signed-off-by: ArnabDutta01 <rickkdutta@gmail.com>
Mixed activityActivity patterns show a mix of organic and automated signals. Evidence
This is an automated analysis by AgentScan |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #14391 +/- ##
==========================================
+ Coverage 99.12% 99.13% +0.01%
==========================================
Files 135 135
Lines 53661 54638 +977
Branches 2737 2808 +71
==========================================
+ Hits 53191 54166 +975
- Misses 356 357 +1
- Partials 114 115 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
Confidence Score: 5/5
[Medium impact] The PR appears safe to merge. Reviews (3) · Last reviewed commit: "Mention the %%P change in the release no..." · Reviewed by Greptile |
Signed-off-by: ArnabDutta01 <rickkdutta@gmail.com>
chrikrah
left a comment
There was a problem hiding this comment.
This now matches the %% row in docs/logging.rst, and I'm approving it.
Splitting on %% before the atom lookup also fixes %%P, not only the %%% crash. The old test_access_logger_format expectation recorded the bug, so changing it is right.
# exported d3e6278, Python 3.12, AIOHTTP_NO_EXTENSIONS=1
$ pytest tests/test_web_log.py --no-cov -q
22 passed in 2.72s
# aiohttp/web_log.py from base fe09949, tests kept
6 failed, 16 passed in 2.06s
$ pre-commit run --all-files # every hook passed
$ mypy # mypy 2.4.1: 9 errors, all in worker.py, compression_utils.py, test_worker.py
non-blocking: %%P used to log % plus the pid and now logs %P, but CHANGES/14390.bugfix.rst only mentions the crash. Could you add a clause there for anyone whose format relied on the old output?
Signed-off-by: ArnabDutta01 <rickkdutta@gmail.com>
|
Thanks for testing it. I added a sentence about |
e8773dc to
7c06dba
Compare
What do these changes do?
A literal
%%in the access log format is documented as "The percent sign", butCLEANUP_REturned it into%%%, so every log line failed withError in logging(ValueError: incomplete format). The%that follows%%was also read as the start of an atom, so%%Plogged the process id instead of%P.compile_format()now splits the format on%%, looks up atoms only inside the pieces, and joins the compiled pieces back with%%.Are there changes in behavior for the user?
Formats that contain
%%now log a single%instead of failing on every request.%%followed by an atom letter (for example%%P) now logs the literal text (%P). It used to log%followed by the atom's value.test_access_logger_formatasserted that old compiled form, so I updated its expectation.Is it a substantial burden for the maintainers to support this?
No. The change is a few lines inside
AccessLogger.compile_format()and does not change the public API.Related issue number
Fixes #14390
Checklist
%%as the percent sign)CONTRIBUTORS.txtCHANGES/folderLocal test run
Without the fix (
aiohttp/web_log.pyfrommaster, new tests applied):With the fix:
Drafted with Claude Code (Claude Opus 5.5); reviewed by @ArnabDutta01.