Skip to content

RemoveHeaders

RemoveHeaders strips all message headers matching a glob pattern, with an optional whitelist of header names to preserve. It complements RemoveHeader (single header, in transform) and is typically used to scrub internal/transport headers before publishing a message to an outbound endpoint.

Processors in this file

NewRemoveHeaders

YAML form:

steps:
  - remove-headers:
      pattern: "Helix*"
      except: ["HelixWorkflowId"]
Field Type Default Description
pattern string required Glob pattern (Go filepath.Match syntax). Common patterns: Helix*, X-Internal-*, temp.*.
except list of strings empty Header names to keep even if they match pattern.

Constructor: NewRemoveHeaders(pattern string, except ...string) *RemoveHeaders.

How it works:

  1. Iterates all headers on the In() message.
  2. Skips any header whose name is in the except set.
  3. Tests the remaining names against pattern with filepath.Match. Matches are removed.
  4. Invalid glob patterns are silently skipped (the processor never errors), so a malformed pattern is a no-op rather than data loss.

Pitfalls:

  • The Go glob syntax is not regex. * matches any sequence except path separators; there is no *? lazy quantifier. Use H* not H.*.
  • Pattern matching is case-sensitive on header names.
  • To remove a single header use the remove-header: keyword (see transform).

Examples

workflows:
  - id: scrub-internals-before-send
    trigger: { uri: direct://outbound }
    steps:
      - remove-headers:
          pattern: "Helix*"
          except: ["HelixWorkflowId", "HelixStepId"]
      - target: kafka://outbound-events

Source

pkg/processor/remove_headers.go

See also

  • transform — RemoveHeader for a single header by exact name.
  • convert — RemoveProperties for the same pattern over exchange properties instead of message headers.