Skip to content

TypeError: unhashable type 'dict' in TemplateResponse causes Internal Server Error on fresh deployment #129

@deesk

Description

@deesk

Environment

  • azd version: 1.14+
  • Python: 3.13
  • Starlette: latest
  • Deployment region: eastus
  • OS: Windows 11
  • Date: March 2026

Description

After successful azd up deployment the app returns Internal Server Error on every page load immediately after deployment. No custom code changes were made.

Root Cause

TemplateResponse syntax in src/api/routes.py line 80 uses the old Starlette argument format which is incompatible with current Starlette version.

Steps to Reproduce

  1. Fork repo
  2. Run azd up targeting eastus region
  3. Open deployed Container App URL
  4. Internal Server Error appears immediately

Error Logs

File "/code/api/routes.py", line 80, in index_name
    return templates.TemplateResponse(
File "/usr/local/lib/python3.13/site-packages/starlette/templating.py", line 148
    template = self.get_template(name)
TypeError: unhashable type: 'dict'

Fix

Change src/api/routes.py line 80 from:

return templates.TemplateResponse(
    "index.html", 
    {
        "request": request,
    }
)

To:

return templates.TemplateResponse(
    request=request,
    name="index.html"
)

Additional Notes

  • azd up completes successfully with all 10 resources created
  • gpt-4o-mini model deploys successfully
  • Error occurs immediately on first page load
  • Fix confirmed working after azd deploy
  • Chat functionality verified working after fix
  • RAG/document upload not tested as requires
    separate Azure AI Search configuration

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions