Some produce and consume policies have a failure_mode setting that controls what happens to a record when the policy fails to process it:
|
Failure mode
|
Description
|
Policy type
|
reject
|
Rejects the record batch that holds the record.
|
Produce
|
error
|
Doesn’t deliver the batch to the client on consume, and rejects the record when the policy fails on produce.
|
Consume and produce
|
skip
|
Doesn’t deliver the record to the client.
|
Consume
|
passthrough
|
Delivers the record even though policy execution failed.
|
Consume and produce
|
mark
|
Delivers the record, and Event Gateway adds a kong/policy-failure-<id> header whose value is the reason for the failure (truncated to 512 characters).
|
Consume and produce
|
See each policy for the failure modes it supports.
The mark failure mode attaches the policy failure reason to the record in a kong/policy-failure-<id> header.
On produce, Event Gateway stores the header with the record in the backend cluster.
The header remains on the record, so every consumer of the topic sees it, including systems that never pass through Event Gateway.
A producer with access to the topic can trigger policy failures on purpose and read the failure reasons to learn about your policy configuration.
Warning: Failure reasons can contain runtime-specific information, such as schema IDs, registry URLs, field paths, KMS ARNs and key IDs, KMS error text, JWT issuer and audience data, and CEL expression snippets.
If you use mark, configure a Modify Headers policy that runs after the failing policy to remove the kong/policy-failure-<id> header before the record is stored in the backend cluster or delivered to a client.
The error failure mode stops the delivery of the whole batch that contains the failing record.
The client receives an error with the policy failure reason.
Warning: A single record that always fails the policy, for example one written by a producer with access to the topic, blocks every consumer group at that offset, and recovery requires manual operator action.
Use error sparingly, and prefer skip when producers you don’t trust can write to the topic.
skip stops only the failing record, so consumer groups keep making progress.