Skip to content

M8F-132 - Bugfix - Backend container issue on start up#71

Merged
andrepestana-aot merged 3 commits intoAOT-Technologies:mainfrom
andrepestana-aot:bugfix/M8F-132-backend-container-issue-on-start-up
Mar 11, 2026
Merged

M8F-132 - Bugfix - Backend container issue on start up#71
andrepestana-aot merged 3 commits intoAOT-Technologies:mainfrom
andrepestana-aot:bugfix/M8F-132-backend-container-issue-on-start-up

Conversation

@andrepestana-aot
Copy link
Collaborator

JIRA Ticket

https://aottech.atlassian.net/browse/M8F-132

Description

This PR fixes tenant-aware login and stabilizes Docker runtime configuration for the backend, Celery worker, and Flower.

It also makes tenant realm creation in Keycloak use runtime backend/frontend URLs instead of placeholder-only defaults, and adds test coverage for that behavior.

Bugs Fixed

  • Fixed Celery worker startup so worker/flower do not run API-only database migration behavior on startup.
  • Fixed backend/worker/flower role drift in Docker where services could inherit incorrect runtime flags from .env.
  • Fixed tenant realm login failures in Keycloak caused by newly created realms keeping placeholder or incomplete client redirect/logout URLs.
  • Fixed the tenant selection page so selecting a tenant actually starts the tenant-aware login flow instead of stopping after tenant verification.
  • Fixed backend startup so uvicorn does not reload .env a second time and override container-provided environment values.

What Changed

  • Made Docker Compose service-specific environment settings explicit for:
    • m8flow-celery-worker
    • m8flow-celery-flower
  • Updated tenant realm template filling in keycloak_service.py to inject runtime backend/frontend redirect URIs, post-logout URIs, and web origins for generated clients.
  • Added unit tests covering runtime URL injection for backend and frontend Keycloak clients.
  • Updated TenantSelectPage.tsx to redirect directly into /login?tenant=...&authentication_identifier=... after tenant validation.
  • Updated worker startup scripts to force worker-safe flags for scheduler and migrations.
  • Removed the extra uvicorn --env-file usage from backend launch scripts.
  • Updated sample configuration defaults/comments to reflect the intended backend vs worker behavior.

Type

  • Feature
  • Bug fix
  • Documentation
  • Other

Changes

  • Backend
  • Frontend
  • Documentation

Testing

  • Recreation of all Docker containers and volumes (WARNING: DESTRUCTIVE):
    • Remove all containers and volumes for m8flow: docker compose -f docker/m8flow-docker-compose.yml down --volumes --remove-orphans --rmi local
    • Copy sample.env to .env and replace all <LOCAL_IP> to your local IP. Turn multi tenant on: MULTI_TENANT_ON=true
    • Build (no cache): docker compose -f docker/m8flow-docker-compose.yml build --no-cache
    • Put all containers up: docker compose -f docker/m8flow-docker-compose.yml up -d
    • Create a tenant and set a user's password.
    • Log into the tenant with the selected user.
    • Create a process model and verify it's working with no errors.
  • Added unit coverage for Keycloak tenant client URL injection.

Related Issues

Closes #

@andrepestana-aot andrepestana-aot self-assigned this Mar 11, 2026
@andrepestana-aot andrepestana-aot changed the title bug fixes M8F-132 - Bugfix - Backend container issue on start up Mar 11, 2026
@andrepestana-aot andrepestana-aot marked this pull request as ready for review March 11, 2026 02:17

python -m uvicorn extensions.app:app \
--host 0.0.0.0 --port 8000 \
--env-file "$repo_root/.env" \
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just verifying whether removing this could result in local runs silently missing the configuration?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

--env-file "$repo_root/.env" made uvicorn load .env again after the wrapper script had already loaded it.

In the current launcher, .env is read manually in extensions/m8flow-backend/bin/run_m8flow_backend.sh:11 , and it only exports a key if that key is not already set in the environment at extensions/m8flow-backend/bin/run_m8flow_backend.sh:32

When uvicorn also got --env-file, it did a second .env load inside the server startup path. That bypassed the script’s “only if unset” rule, so values from .env could overwrite values already provided by Docker or the parent shell.

export const M8FLOW_TENANT_STORAGE_KEY = 'm8flow_tenant';

const getRedirectUrl = () =>
encodeURIComponent(`${window.location.origin}/`);
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you check the sonar issue here

Copy link
Collaborator

@sonal-aot sonal-aot left a comment

Choose a reason for hiding this comment

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

Make sure all possible Sonar findings have been resolved.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
21 Security Hotspots

See analysis details on SonarQube Cloud

@andrepestana-aot andrepestana-aot merged commit f12e8c1 into AOT-Technologies:main Mar 11, 2026
8 of 9 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