Skip to content

Schema-validation failure does not honor failureStrategy: 'dlq' #23

@iifawzi

Description

@iifawzi

Summary

The README documents messageSchema.failureStrategy: 'dlq' as: "Invalid messages are sent directly to the DLQ without being sent to the processor."

The code does not implement this. Schema-invalid messages take the same path as handler-failed messages: they get retried attempts times (with the configured delay) before reaching DLQ. For a message that fails its schema, no amount of retrying will make it valid — this is pure dead time and broker churn.

Where

  • src/core/serializers/deserializer/DefaultDeserializer.ts:47-57

Current behavior

if (processorConfig.messageSchema) {
    const {type, schema} = processorConfig.messageSchema;
    const validator = getValidator<T>(type);
    if (!validator.validate(schema, typedParsed.message)) {
        throw new RunMQSchemaValidationError(...);  // becomes a normal handler error
    }
}

failureStrategy is destructured into the type but never read. The thrown error joins the regular retry pipeline.

Proposed fix

Treat RunMQSchemaValidationError specially in the consumer chain when failureStrategy === 'dlq':

  • Publish the original message to the DLQ directly.
  • Ack the original.
  • Bypass the retry counter entirely.

Implementation options:

  1. Add a RunMQSchemaFailureProcessor layer in the chain that catches RunMQSchemaValidationError and routes to DLQ.
  2. Surface a permanent: true flag on the error type that RunMQRetriesCheckerProcessor honors as immediate-DLQ.

Acceptance criteria

  • Schema-invalid message with failureStrategy: 'dlq' lands in DLQ on first delivery.
  • No retries are scheduled for schema-invalid messages.
  • Behavior matches the README description.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcriticalCritical severityreleased

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions