Skip to content

Always mount subscription router (demo-safe) and prevent duplicate router mounts#445

Merged
AJaySi merged 1 commit into
mainfrom
codex/ensure-api.subscription.router-always-included
Apr 3, 2026
Merged

Always mount subscription router (demo-safe) and prevent duplicate router mounts#445
AJaySi merged 1 commit into
mainfrom
codex/ensure-api.subscription.router-always-included

Conversation

@AJaySi
Copy link
Copy Markdown
Owner

@AJaySi AJaySi commented Mar 30, 2026

Motivation

  • Ensure api.subscription endpoints (payment/preflight/subscription) are always available regardless of demo or special modes.
  • Avoid double-registration of the same router which can cause duplicate routes or inclusion errors when core and safety-net paths both run.
  • Preserve existing middleware behavior (API key injection, rate limiting, monitoring) so subscription-related middleware remains active in demo mode.

Description

  • Add _included_router_names tracking to RouterManager and make include_router_safely skip already-included routers to prevent duplicates.
  • Make subscription router an explicit first-class include inside RouterManager.include_core_routers so it is mounted even in demo scenarios.
  • Add a safety-net call to router_manager.include_router_safely(subscription_router, "subscription") in both backend/app.py and backend/main.py to guarantee subscription routes remain mounted if core inclusion changes.
  • Add lightweight logging for demo_mode in RouterManager while leaving middleware registration/order unchanged.

Testing

  • Ran python -m py_compile backend/alwrity_utils/router_manager.py backend/app.py backend/main.py, which completed successfully.

Codex Task

@AJaySi AJaySi merged commit c652c0d into main Apr 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant