Skip to content

Multiple issues preventing user registration API from working with Docker setup #349

@YtimoDeng

Description

@YtimoDeng

⚠️ AI-Assisted Content Notice

This issue was identified with the assistance of AI (Claude) during a learning process. I am a developer learning modular monolith architecture with DDD but not familiar with .NET. I'm using AI to help clarify concepts and troubleshoot the environment setup. While the issues and solutions described below were discovered through this process, they represent real problems preventing the Docker setup from working.


Context

Testing Environment:

  • Commit: 91c8ef24b4cb6ef558c95d8267fa07d68c7059f8
  • Setup: Fresh Docker Compose deployment following repository instructions

Background: As someone new to .NET but interested in learning DDD patterns through this excellent reference project, I attempted to run the application using the provided Docker setup. During this process, I encountered multiple blocking issues that prevented the user registration API from functioning.


Description

When running the application using Docker Compose, the user registration API (POST /userAccess/UserRegistrations) fails with a 500 error due to three separate issues that need to be fixed.

Environment

  • Docker Compose setup
  • SQL Server 2022 (latest)
  • .NET 8.0
  • Commit: 91c8ef24b4cb6ef558c95d8267fa07d68c7059f8

Issues Found

Issue 1: Missing RegistrationsAutofacModule Registration in Startup.cs

Location: src/API/CompanyName.MyMeetings.API/Startup.cs (Line 82-88)

Problem: The ConfigureContainer method is missing the registration for RegistrationsAutofacModule, causing dependency injection to fail when resolving IRegistrationsModule.

Current Code:

public void ConfigureContainer(ContainerBuilder containerBuilder)
{
    containerBuilder.RegisterModule(new MeetingsAutofacModule());
    containerBuilder.RegisterModule(new AdministrationAutofacModule());
    containerBuilder.RegisterModule(new UserAccessAutofacModule());
    containerBuilder.RegisterModule(new PaymentsAutofacModule());
    // Missing: RegistrationsAutofacModule
}

Error:

System.InvalidOperationException: Unable to resolve service for type 'CompanyName.MyMeetings.Modules.Registrations.Application.Contracts.IRegistrationsModule'

Proposed Fix:

Add the missing module registration:

  containerBuilder.RegisterModule(new RegistrationsAutofacModule());

Also need to add the using statement at the top of Startup.cs:

  using CompanyName.MyMeetings.API.Modules.Registrations;

And create the missing file src/API/CompanyName.MyMeetings.API/Modules/Registrations/RegistrationsAutofacModule.cs:

  using Autofac;
  using CompanyName.MyMeetings.Modules.Registrations.Application.Contracts;
  using CompanyName.MyMeetings.Modules.Registrations.Infrastructure;

  namespace CompanyName.MyMeetings.API.Modules.Registrations
  {
      public class RegistrationsAutofacModule : Module
      {
          protected override void Load(ContainerBuilder builder)
          {
              builder.RegisterType<RegistrationsModule>()
                  .As<IRegistrationsModule>()
                  .InstancePerLifetimeScope();
          }
      }
  }

Issue 2: Incorrect sqlcmd Path in Database entrypoint.sh

Location: src/Database/entrypoint.sh (Line 15)

Problem: The script uses an outdated path for sqlcmd that doesn't exist in the SQL Server 2022 container, preventing the database from being created.

Current Code:

/opt/mssql-tools/bin/sqlcmd -d master -i /scripts/CreateDatabase_Linux.sql -U sa -P Test@12345

Error:

/entrypoint.sh: line 15: /opt/mssql-tools/bin/sqlcmd: No such file or directory

Proposed Fix:

Update to the correct path and add the -C flag:

/opt/mssql-tools18/bin/sqlcmd -d master -i /scripts/CreateDatabase_Linux.sql -U sa -P Test@12345 -C


Issue 3: Copy-Paste Errors in View Definitions (Schema Mismatch)

Location: src/Database/CompanyName.MyMeetings.Database/Scripts/CreateStructure.sql (Lines 939-968)

Problem: There are copy-paste errors affecting two consecutive view definitions where the comments and actual CREATE statements don't match.

3a. v_UserRegistrations - Wrong Schema in CREATE Statement

Lines 939-954

The comment says it's creating [registrations].[v_UserRegistrations] (correct), but the actual CREATE VIEW uses [users] schema (wrong).

Current Code (Incorrect):

  PRINT N'Creating [registrations].[v_UserRegistrations]...';

  GO
  CREATE VIEW [users].[v_UserRegistrations]
  AS
  SELECT
      [UserRegistration].[Id],
      [UserRegistration].[Login],
      [UserRegistration].[Email],
      [UserRegistration].[FirstName],
      [UserRegistration].[LastName],
      [UserRegistration].[Name],
      [UserRegistration].[StatusCode]
  FROM [registrations].[UserRegistrations] AS [UserRegistration]
  GO

Note: The schema should be [registrations] not [users], and the Password field is missing.

Error:

System.Data.SqlClient.SqlException: Invalid object name 'registrations.v_UserRegistrations'.

Proposed Fix:

  1. Line 943: Change CREATE VIEW [users].[v_UserRegistrations] to CREATE VIEW [registrations].[v_UserRegistrations]
  2. Line 952: Add missing [UserRegistration].[Password] field after StatusCode

Reference: The correct definition exists at src/Database/CompanyName.MyMeetings.Database/Structure/registrations/Views/v_UserRegistrations.sql

3b. v_UserPermissions - Wrong Schema in PRINT Comment

Lines 955-968

The comment says it's creating [registrations].[v_UserPermissions] (wrong), but the actual CREATE VIEW correctly uses [users] schema.

Current Code:

  PRINT N'Creating [registrations].[v_UserPermissions]...';

  GO
  CREATE VIEW [users].[v_UserPermissions]
  AS
  SELECT
      DISTINCT
      [UserRole].UserId,
      [RolesToPermission].PermissionCode
  FROM [users].UserRoles AS [UserRole]
      INNER JOIN [users].RolesToPermissions AS [RolesToPermission]
          ON [UserRole].RoleCode = [RolesToPermission].RoleCode
  GO

Note: The PRINT comment should say [users] not [registrations].

Proposed Fix:

Line 955: Change comment to PRINT N'Creating [users].[v_UserPermissions]...';

Reference: The correct definition exists at src/Database/CompanyName.MyMeetings.Database/Structure/users/Views/v_UserPermissions.sql

Root Cause Analysis:

This appears to be a classic copy-paste error where the two view definitions were likely copied together, and during editing:

  • The v_UserRegistrations CREATE statement was accidentally left with [users] schema
  • The v_UserPermissions PRINT comment was accidentally left with [registrations] schema

This suggests the schemas got swapped between the two definitions during copy-paste.


Steps to Reproduce

  1. Clone the repository at commit 91c8ef2
  2. Run docker-compose up -d
  3. Wait for all services to start
  4. Try to register a new user:
  curl -X POST "http://localhost:5001/userAccess/UserRegistrations" \
    -H "Content-Type: application/json" \
    -d '{
      "Login": "testuser",
      "Password": "Test@123",
      "Email": "test@example.com",
      "FirstName": "Test",
      "LastName": "User",
      "ConfirmLink": "http://localhost/confirm"
    }'
  1. Observe 500 Internal Server Error

Expected Behavior

The API should return 200 OK and create a user registration in the database.

Actual Behavior

The API returns 500 Internal Server Error due to the issues listed above.


Impact

These issues prevent the user registration functionality from working in a fresh Docker setup, making it difficult for developers (especially those new to .NET) to get started with the project and observe the DDD patterns in action.


Additional Notes

  • After applying all three fixes, the user registration API works correctly
  • The Outbox pattern can be observed working as expected (events are persisted to registrations.OutboxMessages and processed)
  • Despite being identified through AI assistance, these are genuine bugs that affect the Docker deployment workflow

Acknowledgment

While AI assisted in identifying these issues, I'm happy to test any proposed fixes or provide additional information if needed. This project is an excellent learning resource for DDD concepts, and I hope these findings help improve the getting-started experience for other learners.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions