Skip to content

fix(log): fix typo in log macro accessing non-existent 'access' key - #609

Open
pecastro wants to merge 1 commit into
nginx:mainfrom
pecastro:fix/log-macro-gzip-bug
Open

fix(log): fix typo in log macro accessing non-existent 'access' key#609
pecastro wants to merge 1 commit into
nginx:mainfrom
pecastro:fix/log-macro-gzip-bug

Conversation

@pecastro

@pecastro pecastro commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Inside the 'log' macro, the template iterates over log['access'] entries using '{% for log in log['access'] %}'. Within this loop, each 'log' is an individual access log entry dict with keys: path, format, buffer, gzip, flush, if.

The gzip conditional on line 193 (http) / line 65 (stream) contained a typo: it accessed log['access']['gzip'] instead of log['gzip']. Since entry dicts have no 'access' key, this caused an UndefinedError in Jinja2 3.x (which no longer silently returns Undefined for missing dict keys).

Additionally, the condition only handled string values for gzip, but the defaults document gzip can be a number (e.g., 'gzip: 5'). The condition now also accepts numeric types.

Fixes: log['access']['gzip'] -> log['gzip']
Adds: (log['gzip'] is string or log['gzip'] is number)

Proposed changes

Describe the use case and detail of the change. If this PR addresses an issue on GitHub, make sure to include a link to that issue using one of the supported keywords in this PR's description or commit message.

Checklist

Before creating a PR, run through this checklist and mark each as complete:

Inside the 'log' macro, the template iterates over log['access'] entries
using '{% for log in log['access'] %}'. Within this loop, each 'log'
is an individual access log entry dict with keys: path, format, buffer,
gzip, flush, if.

The gzip conditional on line 193 (http) / line 65 (stream) contained a
typo: it accessed log['access']['gzip'] instead of log['gzip']. Since
entry dicts have no 'access' key, this caused an UndefinedError in
Jinja2 3.x (which no longer silently returns Undefined for missing
dict keys).

Additionally, the condition only handled string values for gzip, but
the defaults document gzip can be a number (e.g., 'gzip: 5'). The
condition now also accepts numeric types.

Fixes: log['access']['gzip'] -> log['gzip']
Adds: (log['gzip'] is string or log['gzip'] is number)
@pecastro
pecastro requested a review from a team as a code owner July 11, 2026 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant