Cover custom log_format URI variables in botlog#10
Merged
Conversation
- Extract resolveURI helper walking the nginx URI variables in priority order: $request_uri, $request, $uri (+ $args / $query_string). Single source of truth for both gonx text path and JSON map path; closure-based accessor stays stack-allocated - Add joinPathArgs to recombine $uri and $args from log_formats that split path and query across two fields (key=value style) - Always strip query before normalizePath so utm/session params cannot reach Prometheus uri labels even if an operator logs $request_uri under the "uri" field name - Cover the new branches: separate $uri/$args, $query_string alias, $request_uri directly, hybrid combined + key=value with internal rewrite, comma-rich query strings, base64 token URLs, and the metric-URI-stays-clean invariant
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.
Summary
Follow-up to #9. After rolling out the query-params fix, real-world logs showed two formats the priority chain missed:
$uriand$argsfields (uriPath="$uri" uriQuery="$args") — bot-log got path-only URIs, the original bug came back for this style."$request"andru="$request_uri"plusu="$uri"(post-rewrite internal path).Changes
resolveURI(get func(string) string)walking nginx URI variables in priority order:$request_uri→$request→$uri(+ optional$args/$query_string). Single source of truth for both gonx text path and JSON map path. Closures stay stack-allocated (func literal does not escapepergcflags -m).joinPathArgs(path, args)to recombine split fields.normalizePathin every branch — defense in depth soutm/sessionparams can never reach Prometheusurilabels even if an operator logs$request_uriunder theurifield name by mistake.Test plan
make fmt lint test— 0 issues, all greenTestParsedLine_RawURIUnnormalized(13 total):$uri+$args(the immediate regression)$args(must not append?)$query_stringalias$request_uridirectly$request_uriwins over post-rewrite$uri)$uricarries query (defensive)$requestlog formats now carry the full URI