Skip to content

fix: resolve LLM admin router db session and add favicon redirect#2582

Merged
crivetimihai merged 2 commits intomainfrom
doc-audit
Jan 30, 2026
Merged

fix: resolve LLM admin router db session and add favicon redirect#2582
crivetimihai merged 2 commits intomainfrom
doc-audit

Conversation

@crivetimihai
Copy link
Copy Markdown
Member

Summary

  • Fix LLM admin router endpoints that returned 500 errors due to db session being None from RBAC middleware (intentionally closed to prevent idle-in-transaction). Added explicit db: Session = Depends(get_db) to all 11 affected endpoints.
  • Add /favicon.ico redirect to /static/favicon.ico for browser compatibility
  • Update README.md Running section with clear table documenting the three running modes

Changes

LLM Admin Router (mcpgateway/routers/llm_admin_router.py)

The get_current_user_with_permissions middleware sets db: None to prevent idle-in-transaction issues. Endpoints that relied on current_user_ctx["db"] failed with AttributeError: 'NoneType' object has no attribute 'execute'.

Fixed endpoints:

  • GET /admin/llm/providers/html
  • GET /admin/llm/models/html
  • GET /admin/llm/api-info/html
  • POST /admin/llm/providers
  • PUT /admin/llm/providers/{provider_id}
  • DELETE /admin/llm/providers/{provider_id}
  • POST /admin/llm/providers/{provider_id}/sync
  • POST /admin/llm/models
  • PUT /admin/llm/models/{model_id}
  • DELETE /admin/llm/models/{model_id}
  • POST /admin/llm/models/test

Favicon Redirect (mcpgateway/main.py)

Browsers request /favicon.ico at the root path, but the file is served at /static/favicon.ico. Added a 301 redirect.

README.md

Added "Quick Reference" table documenting the three running modes:

Command Server Port Database
make dev Uvicorn 8000 SQLite
make serve Gunicorn 4444 SQLite
make compose-up Docker + Nginx 8080 PostgreSQL + Redis

Test plan

  • Verified favicon returns 301 redirect to /static/favicon.ico
  • Verified LLM Settings > Providers tab loads without 500 errors
  • Verified LLM Settings > Models tab loads without 500 errors
  • Verified LLM Settings > Test tab loads without 500 errors
  • Flake8 passes

- Fix LLM admin router endpoints that failed with 500 errors due to
  db session being None from RBAC middleware (intentionally closed
  to prevent idle-in-transaction). Added explicit db: Session =
  Depends(get_db) to all 11 affected endpoints.

- Add /favicon.ico redirect to /static/favicon.ico for browser
  compatibility (browsers request favicon at root path).

- Update README.md Running section with clear table documenting
  the three running modes (make dev, make serve, docker-compose)
  with their respective ports, servers, and databases.

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
…heck

The require_permission decorator only searches kwargs for user context.
sync_provider_models was calling fetch_provider_models with positional
args, causing the decorator to raise 401 Unauthorized.

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
@crivetimihai crivetimihai merged commit a4fa207 into main Jan 30, 2026
52 of 53 checks passed
@crivetimihai crivetimihai deleted the doc-audit branch January 30, 2026 09:07
@crivetimihai crivetimihai added this to the Release 1.0.0-RC1 milestone Jan 31, 2026
hughhennelly pushed a commit to hughhennelly/mcp-context-forge that referenced this pull request Feb 8, 2026
…M#2582)

* fix: resolve LLM admin router db session and add favicon redirect

- Fix LLM admin router endpoints that failed with 500 errors due to
  db session being None from RBAC middleware (intentionally closed
  to prevent idle-in-transaction). Added explicit db: Session =
  Depends(get_db) to all 11 affected endpoints.

- Add /favicon.ico redirect to /static/favicon.ico for browser
  compatibility (browsers request favicon at root path).

- Update README.md Running section with clear table documenting
  the three running modes (make dev, make serve, docker-compose)
  with their respective ports, servers, and databases.

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>

* fix(llm-admin): pass kwargs to fetch_provider_models for permission check

The require_permission decorator only searches kwargs for user context.
sync_provider_models was calling fetch_provider_models with positional
args, causing the decorator to raise 401 Unauthorized.

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>

---------

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Signed-off-by: hughhennnelly <hughhennelly06@gmail.com>
kcostell06 pushed a commit to kcostell06/mcp-context-forge that referenced this pull request Feb 24, 2026
…M#2582)

* fix: resolve LLM admin router db session and add favicon redirect

- Fix LLM admin router endpoints that failed with 500 errors due to
  db session being None from RBAC middleware (intentionally closed
  to prevent idle-in-transaction). Added explicit db: Session =
  Depends(get_db) to all 11 affected endpoints.

- Add /favicon.ico redirect to /static/favicon.ico for browser
  compatibility (browsers request favicon at root path).

- Update README.md Running section with clear table documenting
  the three running modes (make dev, make serve, docker-compose)
  with their respective ports, servers, and databases.

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>

* fix(llm-admin): pass kwargs to fetch_provider_models for permission check

The require_permission decorator only searches kwargs for user context.
sync_provider_models was calling fetch_provider_models with positional
args, causing the decorator to raise 401 Unauthorized.

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>

---------

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
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.

1 participant