fix: update TemplateResponse calls for Starlette 1.0 compatibility#94
Open
ayazhankadessova wants to merge 1 commit intosugarlabs:mainfrom
Open
fix: update TemplateResponse calls for Starlette 1.0 compatibility#94ayazhankadessova wants to merge 1 commit intosugarlabs:mainfrom
ayazhankadessova wants to merge 1 commit intosugarlabs:mainfrom
Conversation
Starlette 1.0 (shipped with FastAPI 0.135+) changed the
TemplateResponse API. The request object is now a required first
positional argument instead of being passed inside the context dict.
Old: TemplateResponse("name.html", {"request": request, ...})
New: TemplateResponse(request, "name.html", context={...})
Without this fix, every HTML page returns a 500 error:
TypeError: unhashable type: 'dict'
Updated all TemplateResponse calls across web, auth, admin, and
main route modules.
This was referenced Mar 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Every HTML page in Sugar-AI returns a 500 Internal Server Error when installed with current dependencies:
This affects the welcome page (
/), dashboard (/dashboard), admin panel (/admin), OAuth login (/oauth-login), admin login (/admin-login), and key request (/request-key) pages.Root Cause
requirements.txthas unpinnedfastapi, which now installs Starlette 1.0. Starlette 1.0 changed theTemplateResponseAPI — therequestobject is now a required first positional argument instead of being passed inside the context dict:Steps to Reproduce
pip install -r requirements.txt(installs FastAPI 0.135+ with Starlette 1.0)DEV_MODE=1 uvicorn main:app --host 0.0.0.0 --port 8000http://localhost:8000/→ 500 errorFix
Updated all 9
TemplateResponsecalls across 4 route modules to use the Starlette 1.0 API.Files Changed
app/routes/web.py— welcome page and dashboardapp/routes/main.py— root welcome pageapp/routes/admin.py— admin panelapp/routes/auth.py— OAuth login, admin login, key request pagesTesting
After the fix, all pages load correctly:
GET /— welcome page rendersGET /oauth-login— login page rendersGET /admin-login— admin login rendersGET /request-key— key request form renders/ask,/ask-llm,/ask-llm-prompted) are unaffected (JSON, no templates)