Skip to content

M8F-152: Fix NATS consumer initialization error #80

Merged
auslin-aot merged 1 commit intoAOT-Technologies:mainfrom
sonal-aot:bugfix/M8F-152-nats-initialization-error
Mar 19, 2026
Merged

M8F-152: Fix NATS consumer initialization error #80
auslin-aot merged 1 commit intoAOT-Technologies:mainfrom
sonal-aot:bugfix/M8F-152-nats-initialization-error

Conversation

@sonal-aot
Copy link
Collaborator

@sonal-aot sonal-aot commented Mar 16, 2026

JIRA Ticket

M8F-152

Description

This PR optimizes the orchestration of NATS-related services by making them optional via Docker Compose profiles and environment variable configuration. It also addresses a database race condition by disabling migrations in the NATS consumer container.

Type

  • Feature
  • Bug fix
  • Documentation
  • Other

Changes

  • Backend
  • Frontend
  • Documentation

Changes Details

  • NATS Service Profiles: Implemented Docker Compose profiles for NATS services. The nats and m8flow-nats-consumer services are now assigned to the nats profile, preventing them from starting by default during a standard docker compose up.
  • Optional Dependencies: Added required: false to the nats service dependencies in both m8flow-backend and m8flow-nats-consumer. This ensures the Docker Compose project remains valid and can start the remaining services even when the nats profile is inactive.
  • Default Configuration: Updated sample.env to set M8FLOW_NATS_ENABLED=false by default. Modified m8flow-docker-compose.yml to dynamically inherit this value across services.
  • Race Condition Fix: Resolved sqlalchemy.exc.NoSuchTableError by disabling database migrations in the m8flow-nats-consumer container (M8FLOW_BACKEND_UPGRADE_DB: "false"). This ensures only the main backend handles schema updates, preventing the consumer from attempting migrations before tables are created.

Testing

  • Standard Startup: Verified the application boots correctly using docker compose up -d (NATS services remain stopped).
  • NATS Enabled Startup: Verified NATS services start correctly when explicitly requested via docker compose --profile nats up -d.
  • Migration Verification: Confirmed the NATS consumer no longer attempts to run migrations, resolving the startup crash.

Related Issues

Closes #

Copy link
Collaborator

@andrepestana-aot andrepestana-aot left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks!

Copy link
Collaborator

@auslin-aot auslin-aot left a comment

Choose a reason for hiding this comment

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

please resolve conflicts

@sonal-aot sonal-aot force-pushed the bugfix/M8F-152-nats-initialization-error branch from 56bb82d to 0fd3cee Compare March 19, 2026 07:16
@sonarqubecloud
Copy link

@auslin-aot auslin-aot merged commit edce0e5 into AOT-Technologies:main Mar 19, 2026
11 of 12 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.

4 participants