Skip to content

Conversation

@kibertoad
Copy link
Owner

@kibertoad kibertoad commented Dec 14, 2025

Summary by CodeRabbit

  • New Features

    • Clearer guidance when calling deprecated publish methods.
  • Tests

    • Expanded coverage for publishers, consumers, queue/topic management, error resolution, and utility helpers; added multiple new test suites.
  • Chores

    • Package bumped to 23.0.0 and dependencies/dev-dependencies updated.
    • Test runner config adjusted (maxWorkers) and coverage thresholds increased.
    • Minor internal comment/documentation annotations updated.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 14, 2025

Walkthrough

Added v8 coverage-ignore directives across AMQP error paths, relocated a method inside AbstractAmqpPublisher, added multiple tests for error/deprecation cases and queue utilities, updated Vitest config (maxWorkers, coverage thresholds), and bumped package version and dependencies.

Changes

Cohort / File(s) Summary
Coverage ignore directives
packages/amqp/lib/AbstractAmqpPublisher.ts, packages/amqp/lib/AbstractAmqpService.ts, packages/amqp/lib/AmqpConnectionManager.ts, packages/amqp/lib/amqpConnectionResolver.ts
Replaced c8 ignore comments with v8 ignore comment blocks around catch blocks, channel/connection error handlers, and logging/delay sites; no runtime logic changes.
Method relocation
packages/amqp/lib/AbstractAmqpPublisher.ts
Moved the override processMessage(): Promise<Either<'retryLater','success'>> declaration earlier in the class; signature unchanged.
New/expanded tests — managers
packages/amqp/lib/AmqpQueuePublisherManager.spec.ts, packages/amqp/lib/AmqpTopicPublisherManager.spec.ts
Added tests asserting deprecated publish() throws guidance and publishSync() errors for unknown queue/exchange.
New/expanded tests — error resolver & utils
packages/amqp/lib/errors/AmqpConsumerErrorResolver.spec.ts, packages/amqp/lib/utils/AmqpQueueUtils.spec.ts
Added tests for error-to-standardized-error mapping and AMQP queue/exchange ensure/check/delete behaviors (including env-based deletion guards).
New/expanded tests — publishers & consumers
packages/amqp/test/publishers/AmqpPermissionPublisher.spec.ts, packages/amqp/test/consumers/AmqpPermissionConsumer.spec.ts
Added tests for missing publisher config, abstract-method behavior throwing, empty-message ignore, and schema validation rejection.
Config & manifest
packages/amqp/vitest.config.ts, packages/amqp/package.json
Vitest: replaced poolOptions with maxWorkers: 1 and raised coverage thresholds (lines 89→90, branches 79→80, statements 89→90). package.json: bumped version to 23.0.0 and updated dependencies/peer/dev deps.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–30 minutes

  • Focus review on:
    • packages/amqp/lib/AbstractAmqpPublisher.ts — relocated processMessage declaration for ordering/inheritance implications.
    • New tests that interact with live AMQP state and environment (CI flakiness risk).
    • packages/amqp/vitest.config.ts — change from poolOptions to maxWorkers and raised coverage thresholds for CI impact.

Possibly related PRs

  • chore: Fix lint #350 — edits touching packages/amqp/lib/AbstractAmqpPublisher.ts (diagnostic/coverage directive adjustments).

Suggested labels

minor

Suggested reviewers

  • CarlosGamero

Poem

🐇
I hopped through handlers, quiet and spry,
Tucked v8 flags where errors lie.
Tests now guard the queues and streams,
Version bumped for brighter dreams.
A tiny hop — the CI hums "goodbye!"

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: improving test coverage across AMQP package files and bumping the version to 23.0.0 for release.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/amqp-coverage

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
packages/amqp/lib/utils/AmqpQueueUtils.spec.ts (2)

105-116: Consider adding success path tests for ensureAmqpQueue.

The test suite only covers the error case when neither config is provided. Consider adding tests for:

  • Success with creationConfig (calls assertQueue)
  • Success with locatorConfig (verifies queue exists)

This would align with the PR objective to improve coverage and match the comprehensive testing pattern used for ensureExchange.


118-129: Consider adding success path tests for ensureAmqpTopicSubscription.

Similar to ensureAmqpQueue, only the error case is tested. Consider adding:

  • Success with creationConfig (asserts exchange, binds queue)
  • Success with locatorConfig (verifies exchange exists)

This would provide more complete coverage consistent with the PR objective.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7eb1dc1 and fb962cc.

📒 Files selected for processing (12)
  • packages/amqp/lib/AbstractAmqpPublisher.ts (3 hunks)
  • packages/amqp/lib/AbstractAmqpService.ts (3 hunks)
  • packages/amqp/lib/AmqpConnectionManager.ts (2 hunks)
  • packages/amqp/lib/AmqpQueuePublisherManager.spec.ts (1 hunks)
  • packages/amqp/lib/AmqpTopicPublisherManager.spec.ts (1 hunks)
  • packages/amqp/lib/amqpConnectionResolver.ts (1 hunks)
  • packages/amqp/lib/errors/AmqpConsumerErrorResolver.spec.ts (1 hunks)
  • packages/amqp/lib/utils/AmqpQueueUtils.spec.ts (1 hunks)
  • packages/amqp/package.json (2 hunks)
  • packages/amqp/test/consumers/AmqpPermissionConsumer.spec.ts (1 hunks)
  • packages/amqp/test/publishers/AmqpPermissionPublisher.spec.ts (1 hunks)
  • packages/amqp/vitest.config.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
packages/amqp/lib/utils/AmqpQueueUtils.spec.ts (2)
packages/amqp/test/utils/testAmqpConfig.ts (1)
  • TEST_AMQP_CONFIG (3-10)
packages/amqp/lib/utils/amqpQueueUtils.ts (4)
  • checkExchangeExists (30-45)
  • ensureAmqpQueue (47-61)
  • ensureAmqpTopicSubscription (63-84)
  • deleteAmqpQueue (102-122)
packages/amqp/test/consumers/AmqpPermissionConsumer.spec.ts (2)
packages/amqp/test/consumers/AmqpPermissionConsumer.ts (1)
  • AmqpPermissionConsumer (39-115)
packages/core/lib/index.ts (2)
  • objectToBuffer (107-107)
  • waitAndRetry (109-109)
packages/amqp/test/publishers/AmqpPermissionPublisher.spec.ts (1)
packages/amqp/test/publishers/AmqpPermissionPublisher.ts (1)
  • AmqpPermissionPublisher (19-54)
🪛 GitHub Check: general (20.x, @message-queue-toolkit/amqp) / build
packages/amqp/lib/utils/AmqpQueueUtils.spec.ts

[failure] 7-7: lib/utils/AmqpQueueUtils.spec.ts
Error: Cannot find module './AmqpQueueUtils.ts' imported from '/home/runner/work/message-queue-toolkit/message-queue-toolkit/packages/amqp/lib/utils/AmqpQueueUtils.spec.ts'
❯ lib/utils/AmqpQueueUtils.spec.ts:7:1

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: { code: 'ERR_MODULE_NOT_FOUND' }

🪛 GitHub Check: general (22.x, @message-queue-toolkit/amqp) / build
packages/amqp/lib/utils/AmqpQueueUtils.spec.ts

[failure] 7-7: lib/utils/AmqpQueueUtils.spec.ts
Error: Cannot find module './AmqpQueueUtils.ts' imported from '/home/runner/work/message-queue-toolkit/message-queue-toolkit/packages/amqp/lib/utils/AmqpQueueUtils.spec.ts'
❯ lib/utils/AmqpQueueUtils.spec.ts:7:1

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: { code: 'ERR_MODULE_NOT_FOUND' }

🪛 GitHub Check: general (24.x, @message-queue-toolkit/amqp) / build
packages/amqp/lib/utils/AmqpQueueUtils.spec.ts

[failure] 7-7: lib/utils/AmqpQueueUtils.spec.ts
Error: Cannot find module './AmqpQueueUtils.ts' imported from '/home/runner/work/message-queue-toolkit/message-queue-toolkit/packages/amqp/lib/utils/AmqpQueueUtils.spec.ts'
❯ lib/utils/AmqpQueueUtils.spec.ts:7:1

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: { code: 'ERR_MODULE_NOT_FOUND' }

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: kafka (22.x) / build
  • GitHub Check: kafka (24.x) / build
🔇 Additional comments (20)
packages/amqp/lib/AmqpConnectionManager.ts (1)

30-46: Appropriate use of v8 ignore for async event handlers.

The coverage exclusion for the error and close event handlers is reasonable since these callbacks are triggered asynchronously by the underlying AMQP library during connection failures, making them difficult to exercise reliably in unit tests.

Minor observation (pre-existing, not blocking): The this.reconnectsActive check on line 41 is redundant since it's already verified in the outer condition on line 39.

packages/amqp/lib/amqpConnectionResolver.ts (1)

29-44: Appropriate use of v8 ignore for retry logic.

The coverage exclusion for the catch block and retry logic is reasonable. Testing connection failure scenarios with actual retry delays would result in slow and potentially flaky tests. The retry logic itself (incrementing backoff with retryTime, max attempt check) is straightforward.

packages/amqp/lib/AbstractAmqpService.ts (1)

89-94: Appropriate use of v8 ignore for error handling paths.

The coverage exclusions are appropriate for:

  1. The catch block (lines 89-94) handling channel creation failures
  2. The close and error event handlers (lines 107-120) that are triggered asynchronously

These follow the same pattern as the other AMQP files in this PR and exclude hard-to-test error recovery code paths from coverage metrics.

Also applies to: 107-120

packages/amqp/package.json (2)

3-3: LGTM! Dependency updates align with the 23.0.0 release.

The version bump to 23.0.0 and associated dependency updates are appropriate for a major release. The updates include:

  • Minor updates to existing dependencies
  • Major version bump for Vitest (v3 → v4) with matching coverage provider
  • Zod patch update within v4

Also applies to: 31-31, 40-40, 45-47, 51-53


34-34: Verify the actual version requirement change and compatibility needs.

The peer dependency requirement for @message-queue-toolkit/core is currently >=25.0.0. If this was changed from >=22.0.0 in this PR, confirm whether breaking changes between versions 22-25 actually require this minimum version. If so, consider using ^25.0.0 instead to allow minor/patch updates within the v25.x range while preventing incompatible major versions.

packages/amqp/lib/AbstractAmqpPublisher.ts (2)

85-86: LGTM! v8 ignore directive for hard-to-test error path.

The v8 ignore comment on the lazy init error handler is appropriate, as this error path occurs when async initialization fails after fire-and-forget publish. This is difficult to reliably trigger in tests without complex mocking.


144-167: LGTM! Coverage exclusion for publisher-unsupported methods.

The v8 ignore block correctly excludes abstract methods that are intentionally unimplemented for publishers (they're only used by consumers). The new test in AmqpPermissionPublisher.spec.ts (lines 113-130) verifies these methods throw the expected errors.

packages/amqp/lib/AmqpQueuePublisherManager.spec.ts (2)

128-134: LGTM! Good test for deprecated API.

This test correctly validates that the deprecated publish() method throws an error guiding users to use publishSync() instead. Clear deprecation path.


136-147: LGTM! Good validation for unknown queue error.

This test ensures proper error handling when attempting to publish to a queue that hasn't been registered with the publisher manager. The error message is clear and actionable.

packages/amqp/test/consumers/AmqpPermissionConsumer.spec.ts (2)

422-433: LGTM! Good edge case test for malformed messages.

This test validates that the consumer gracefully handles empty message bodies without processing them or crashing. The test appropriately verifies no side effects occurred (counter unchanged).


435-449: LGTM! Good validation for schema enforcement.

This test ensures that messages missing required fields (like id) are properly rejected by schema validation. The test correctly verifies the error is captured by the error resolver.

packages/amqp/lib/AmqpTopicPublisherManager.spec.ts (2)

93-99: LGTM! Consistent deprecation handling.

This test mirrors the queue publisher manager's deprecation test, ensuring consistent behavior across publisher types. The error message guides users to the correct method.


101-112: LGTM! Good validation for unknown exchange error.

This test ensures proper error handling when attempting to publish to an exchange that hasn't been registered. The error message clearly identifies the missing exchange.

packages/amqp/test/publishers/AmqpPermissionPublisher.spec.ts (2)

101-111: LGTM! Good validation for configuration requirements.

This test ensures the publisher constructor properly validates that either locatorConfig or creationConfig provides a queueName. Clear error message for misconfiguration.


113-130: LGTM! Comprehensive coverage for abstract method stubs.

This test validates that all abstract methods meant only for consumers throw the expected "Not implemented for publisher" error. This provides test coverage for the methods excluded by v8 ignore directives in AbstractAmqpPublisher.ts (lines 144-167), confirming they behave as documented.

packages/amqp/lib/errors/AmqpConsumerErrorResolver.spec.ts (1)

1-86: LGTM! Comprehensive error handling test coverage.

This new test file provides excellent coverage for AmqpConsumerErrorResolver.processError, validating:

  • Correct error type mapping (SyntaxError → MessageInvalidFormatError, ZodError → MessageValidationError)
  • Standardized error handling with proper errorCode extraction
  • Graceful fallback for unexpected error types (null, undefined, strings, unknown objects)

The tests are well-structured and cover all major error scenarios.

packages/amqp/vitest.config.ts (2)

10-10: LGTM! Updated to Vitest v4 configuration.

The change from poolOptions: { threads: { singleThread: true } } to maxWorkers: 1 aligns with Vitest v4's updated configuration API while maintaining the same single-threaded test execution behavior.


16-19: LGTM! Coverage thresholds increased with supporting tests.

The modest coverage threshold increases (lines: 89→90%, branches: 79→80%, statements: 89→90%) are backed by the comprehensive test additions in this PR, including error handling tests, edge case validation, and deprecated API coverage.

packages/amqp/lib/utils/AmqpQueueUtils.spec.ts (2)

28-79: LGTM!

Comprehensive test coverage for ensureExchange with proper resource cleanup and good coverage of both success and error paths.


131-200: LGTM!

Excellent comprehensive coverage of deleteAmqpQueue with all code paths tested, proper environment mocking, and thorough resource cleanup.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/amqp/test/publishers/AmqpPermissionPublisher.spec.ts (1)

113-129: Coverage test for abstract methods is functional.

This test successfully covers the abstract method error paths. The implementation is clean and properly manages resources (init/close).

Minor observation: These tests target abstract method implementations rather than observable publisher behavior. Since the PR explicitly aims to improve coverage and these methods should never be invoked on publishers in practice, this approach achieves its goal. Alternative approaches like integration tests might naturally cover error paths through actual usage, but that would require more complex setup.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 66dfb0f and 23cf0e4.

📒 Files selected for processing (1)
  • packages/amqp/test/publishers/AmqpPermissionPublisher.spec.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/amqp/test/publishers/AmqpPermissionPublisher.spec.ts (1)
packages/amqp/test/publishers/AmqpPermissionPublisher.ts (1)
  • AmqpPermissionPublisher (19-54)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
  • GitHub Check: general (24.x, @message-queue-toolkit/s3-payload-store) / build
  • GitHub Check: general (20.x, @message-queue-toolkit/redis-message-deduplication-store) / build
  • GitHub Check: general (20.x, @message-queue-toolkit/metrics) / build
  • GitHub Check: general (22.x, @message-queue-toolkit/redis-message-deduplication-store) / build
  • GitHub Check: general (22.x, @message-queue-toolkit/gcp-pubsub) / build
  • GitHub Check: general (22.x, @message-queue-toolkit/gcs-payload-store) / build
  • GitHub Check: general (24.x, @message-queue-toolkit/redis-message-deduplication-store) / build
  • GitHub Check: general (24.x, @message-queue-toolkit/metrics) / build
  • GitHub Check: general (20.x, @message-queue-toolkit/sns) / build
  • GitHub Check: general (22.x, @message-queue-toolkit/outbox-core) / build
  • GitHub Check: general (20.x, @message-queue-toolkit/s3-payload-store) / build
  • GitHub Check: general (24.x, @message-queue-toolkit/sqs) / build
  • GitHub Check: general (24.x, @message-queue-toolkit/outbox-core) / build
  • GitHub Check: general (22.x, @message-queue-toolkit/sns) / build
  • GitHub Check: general (22.x, @message-queue-toolkit/schemas) / build
  • GitHub Check: general (24.x, @message-queue-toolkit/gcp-pubsub) / build
  • GitHub Check: general (20.x, @message-queue-toolkit/sqs) / build
  • GitHub Check: general (20.x, @message-queue-toolkit/gcp-pubsub) / build
  • GitHub Check: kafka (22.x) / build
  • GitHub Check: kafka (24.x) / build
🔇 Additional comments (1)
packages/amqp/test/publishers/AmqpPermissionPublisher.spec.ts (1)

101-111: LGTM! Good defensive validation test.

This test properly validates that the constructor enforces the queueName requirement across both configuration options. The use of @ts-expect-error is appropriate for intentionally passing invalid configs to test runtime validation.

@kibertoad kibertoad merged commit f2e4861 into main Dec 14, 2025
38 of 39 checks passed
@kibertoad kibertoad deleted the chore/amqp-coverage branch December 14, 2025 11:58
@coderabbitai coderabbitai bot mentioned this pull request Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants