Skip to content

fix: validate handler topics and transport names - #4

Merged
kamilmysliwiec merged 2 commits into
nestjs:masterfrom
Asadshah7950:fix/validate-handler-topics
Sep 28, 2026
Merged

kamilmysliwiec merged 2 commits into
nestjs:masterfrom
Asadshah7950:fix/validate-handler-topics

Conversation

@Asadshah7950

Copy link
Copy Markdown
Contributor

PR Checklist

PR Type

  • Bugfix

What is the current behavior?

  1. @OnOutboxMessage(topic, options) validates { consumer }, but leaves opic completely unvalidated. Passing an empty string (""), an empty array ([]), or an array with empty/non-string items is silently accepted. An empty array silently registers no handler at all, and an empty string registers a handler on an empty topic that can never be dispatched (since Outbox.add() rejects empty topics).
  2. �ssertTransportName(name) checks for the reserved "local" name, but allows empty or whitespace strings ("", " ").
  3. In ests/support/generate-prisma-client.ts, spawnSync('npm', ...) without { shell: true } fails on Windows platforms with ENOENT.

What is the new behavior?

  1. @OnOutboxMessage validates that opic is a non-empty string or a non-empty array of non-empty strings, failing immediately at decorator evaluation time with a clear descriptive error:
    @OnOutboxMessage("") needs a topic: a non-empty string or array of non-empty strings.
  2. �ssertTransportName explicitly rejects empty or whitespace transport names:
    OutboxModule: transport name cannot be empty. Give the transport intransportsa name.
  3. generatePrismaClient adds { shell: true } to spawnSync for cross-platform compatibility across Windows, macOS, and Linux test runs.
  4. Added unit tests for invalid topic, consumer, and transport name configurations.

Does this PR introduce a breaking change?

  • Yes
  • No

- Reject empty string or empty array topics in @OnOutboxMessage()
- Reject empty transport names in assertTransportName()
- Enable shell in generatePrismaClient for cross-platform test setup
- Add unit test coverage for invalid topics, consumers, and transport names
Share one name rule (a string with more than whitespace) between the decorator,
Outbox.add() and transport names; copy the topics array; reject a topic listed
twice; keep the error readable for values JSON.stringify() can't serialize; run
prisma generate as one command string to avoid DEP0190 on Node 24.
@kamilmysliwiec
kamilmysliwiec merged commit 6079ecf into nestjs:master Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants