Skip to content

fix: remove duplicate router registrations in api/main.py #263

Description

@rajsingh1301

Description

This PR removes duplicate router registrations in api/main.py for the actions.router and context.router modules to prevent duplicate OpenAPI documentation loading and identical route handling.

Why this is necessary

Currently, actions and context routes are safely wrapped within a try...except block, but are then mistakenly registered a second time directly below the exception handling block.

Registering identical routers multiple times on a single FastAPI instance can cause:

  1. Duplicate and cluttered endpoint generation in Swagger/Redoc.
  2. Silent route masking where FastAPI routing resolves against the final registered instance unnecessarily.
  3. Issues in integration tests that validate API schema definitions.

Changes Made

  • Removed duplicate app.include_router(actions.router, prefix="/api/v1")
  • Removed duplicate app.include_router(context.router, prefix="/api/v1")
  • Preserved router bootstrapping through the existing try...except mechanism

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactor (code quality improvement)

Testing

  • Verified Swagger UI displays endpoints without duplication
  • Confirmed API boots successfully without crashes
  • Ensured route registration behaves correctly after removal of duplicate inclusions

Affected File

  • api/main.py

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions