Skip to content

RG-T117 Fixing autofac dep issue - #447

Merged
ucswift merged 1 commit into
masterfrom
develop
Aug 6, 2026
Merged

RG-T117 Fixing autofac dep issue#447
ucswift merged 1 commit into
masterfrom
develop

Conversation

@ucswift

@ucswift ucswift commented Aug 6, 2026

Copy link
Copy Markdown
Member

Pull Request Description

Summary

Fixes an Autofac circular dependency exception (RG-T117) in the chatbot adapter registry by deferring adapter resolution until first use.

Problem

The ChatbotAdapterRegistry eagerly resolved all chatbot platform adapters in its constructor. This triggered a circular dependency chain: WebChatAdapter's notifier depends on chat services, which in turn reach AuthorizationService → CallsService → CommunicationService → ChatbotOutboundService, which loops back into ChatbotAdapterRegistry. This cycle caused Autofac to throw a circular dependency exception during container activation.

Changes

  • ChatbotAdapterRegistry: Changed the constructor parameter from IEnumerable<IChatbotPlatformAdapter> to Lazy<IEnumerable<IChatbotPlatformAdapter>>, and wrapped the adapter dictionary in a Lazy<>. Adapters are now only materialized on the first call to GetAdapter, keeping the circular dependency out of the container's constructor chain.
  • Tests: Updated existing tests to use the new constructor signature and added a new test (Registry_DoesNotResolveAdaptersUntilFirstGetAdapter) verifying that adapters are not resolved until GetAdapter is first invoked.

Impact

Resolves a runtime dependency injection failure that prevented the chatbot subsystem (and its dependents in the communication/calls chain) from initializing correctly.

@Resgrid-Bot

Resgrid-Bot commented Aug 6, 2026

Copy link
Copy Markdown

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug
Performance
Security
Business Logic

Access your configuration settings here.

@request-info

request-info Bot commented Aug 6, 2026

Copy link
Copy Markdown

Thanks for opening this, but we'd appreciate a little more information. Could you update it with more details?

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

ChatbotAdapterRegistry now accepts lazy adapter resolution. It defers adapter enumeration, grouping, and dictionary creation until the first GetAdapter call. Duplicate platforms retain the first adapter, and missing platforms return null.

Changes

Chatbot adapter registry

Layer / File(s) Summary
Deferred adapter registry initialization
Providers/Resgrid.Providers.Chatbot/Services/ChatbotAdapterRegistry.cs
The constructor now accepts Lazy<IEnumerable<IChatbotPlatformAdapter>>. Adapter enumeration and dictionary creation occur on first access. Duplicate platforms retain the first adapter, and missing platforms return null.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title identifies the Autofac dependency issue, which matches the primary change in the pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch develop

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.

@ucswift
ucswift merged commit 8c7ac5f into master Aug 6, 2026
19 checks passed
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.

2 participants