Opened 3 weeks ago

Last modified 3 weeks ago

#37352 assigned Bug

ServerFormatter changed incompatibly in Django 2.1

Reported by: Jacob Walls Owned by: Md. Saikat Islam
Component: Utilities Version: 2.1
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

While developing djangoproject.com, a failing request spewed a large stacktrace to my terminal, as described ​here. Root cause was: that project's logging config extends Django's, and it never caught up with a backward incompatible change in Django 2.1 (#28810) that meant the injection of the server_time variable would only happen for f-string format strings, no longer for %-style format strings.

This breaking change was mentioned during triage but didn't get a response during review.

Of course, I could fix this in djangoproject.com, but it's just as easy to fix it in Django where other projects could benefit.

Proposal: this util:

    def uses_server_time(self):
        return self._fmt.find("{server_time}") >= 0

Should not assume f-string style formatting.

Change History (4)

comment:1 by Jacob Walls, 3 weeks ago

Easy pickings: set

comment:2 by Md. Saikat Islam, 3 weeks ago

Owner: set to Md. Saikat Islam
Status: new → assigned
Triage Stage: Unreviewed → Accepted

I reproduced the issue with a %-style ServerFormatter configuration and confirmed that server_time isn't added to the log record, resulting in a formatting error.

I agree with the proposed approach of making uses_server_time() independent of the {}-style formatting. I'll work on a patch with a regression test covering %-style formatting and submit a PR.

comment:3 by Md. Saikat Islam, 3 weeks ago

Has patch: set
Needs tests: set
Note: See TracTickets for help on using tickets.
Back to Top