fix(brotli): don't log expected non-standard ETag at error level#13545
Open
AlinsRan wants to merge 1 commit into
Open
fix(brotli): don't log expected non-standard ETag at error level#13545AlinsRan wants to merge 1 commit into
AlinsRan wants to merge 1 commit into
Conversation
weak_etag_header() logged `core.log.error("no standard etag or regex match
failed: ", err)` whenever the upstream ETag was not a quoted string, even
though that is an expected case (err is nil) — producing error-level noise
on every such response. Only log at error level when ngx.re.match actually
returns an error, and drop the ETag silently otherwise. Also tighten the
capture from (.*) to ([^"]*) so a malformed ETag with internal quotes is
treated as non-standard rather than weakened.
Signed-off-by: AlinsRan <alinsran@apache.org>
aa03816 to
65c9907
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR
brotli.lualogged an expected non-quoted upstream ETag aterrorlevel (printing... : nil), spamming the error log.Cause
weak_etag_header()downgrades a strongETagto a weak one (Brotli alters the body, so a strong validator no longer holds). When the upstreamETagis not a quoted string the regex simply does not match — an expected case — but the code logs it aterrorlevel with a nilerr:Fix
errorlevel whenngx.re.matchactually returns an error; otherwise drop the ETag silently (behavior unchanged).(.*)to([^"]*)so a malformed ETag containing internal quotes is treated as non-standard (and dropped) rather than weakened into another malformed value.Checklist