header_rewrite: Improve URL Error messages#13261
Open
bneradt wants to merge 1 commit into
Open
Conversation
Old log:
ERROR: [header_rewrite] Rule not supported at this hook
New log:
ERROR: [header_rewrite] Rule not supported at hook=TS_HTTP_READ_RESPONSE_HDR_HOOK: %{TO-URL:URL} in /tmp/sb/header_rewrite_unsupported_url_hook/unsupported_url_hook.conf:18
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves diagnostics from the header_rewrite plugin by enriching ConditionUrl runtime error logs with the executing hook, the specific URL token involved, and (when available) the originating config file and line number. This helps operators quickly locate and fix unsupported URL usages at particular hooks.
Changes:
- Track and propagate config file/line information through
StatementandValueso nested%{...}expansions can report their origin. - Record the active
TSHttpHookIDinResourcesduringgather()so runtime URL failures can include the hook context. - Add a
ConditionUrl::log_error()helper and use it for URL retrieval / unsupported-hook errors with improved message formatting.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| plugins/header_rewrite/value.cc | Propagates config location from the owning Statement into Value and any %{...} conditions created from the value string. |
| plugins/header_rewrite/statement.h | Adds config filename/line storage and accessors to the Statement base class. |
| plugins/header_rewrite/ruleset.cc | Sets config location on created operators/conditions based on parser filename/line. |
| plugins/header_rewrite/resources.h | Adds a hook field to Resources to retain the active hook for error reporting. |
| plugins/header_rewrite/resources.cc | Stores the active hook into Resources::hook at the start of gather(). |
| plugins/header_rewrite/operators.cc | Sets config location on operators/conditions created within OperatorIf. |
| plugins/header_rewrite/conditions.h | Declares ConditionUrl::log_error() helper. |
| plugins/header_rewrite/conditions.cc | Implements hook/URL-type naming helpers and uses log_error() for improved URL-related runtime error messages. |
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.
Old log:
ERROR: [header_rewrite] Rule not supported at this hook
New log:
ERROR: [header_rewrite] Rule not supported at hook=TS_HTTP_READ_RESPONSE_HDR_HOOK: %{TO-URL:URL} in /tmp/sb/header_rewrite_unsupported_url_hook/unsupported_url_hook.conf:18