Skip to content

header_rewrite: Improve URL Error messages#13261

Open
bneradt wants to merge 1 commit into
apache:masterfrom
bneradt:header-rewrite-url-diagnostics
Open

header_rewrite: Improve URL Error messages#13261
bneradt wants to merge 1 commit into
apache:masterfrom
bneradt:header-rewrite-url-diagnostics

Conversation

@bneradt

@bneradt bneradt commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

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

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
Copilot AI review requested due to automatic review settings June 11, 2026 20:37
@bneradt bneradt added this to the 11.0.0 milestone Jun 11, 2026
@bneradt bneradt self-assigned this Jun 11, 2026
@bneradt bneradt added header_rewrite header_rewrite plugin and removed Plugins AuTest labels Jun 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Statement and Value so nested %{...} expansions can report their origin.
  • Record the active TSHttpHookID in Resources during gather() 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

header_rewrite header_rewrite plugin Logging

Projects

Status: No status
Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants