[claude] Fix TemplateResponse signature for Starlette new API (#1114) #1120

Closed
claude wants to merge 1 commits from claude/issue-1114 into main
Collaborator

Fixes #1114

Root cause

Starlette changed TemplateResponse signature from TemplateResponse(name, context) to TemplateResponse(request, name, context). Several routes in routes/tools.py and routes/calm.py still used the old form, passing a string as the first arg and a dict as the second. With the new Starlette, the dict became the name parameter passed to Jinja2’s template cache lookup, which computed tuple([dict]) as the cache key — unhashable, causing TypeError: cannot use ‘tuple’ as a dict key (unhashable type: ‘dict’).

Fix

Updated all 7 old-style TemplateResponse calls in routes/tools.py and routes/calm.py to the new TemplateResponse(request, name, context) signature and removed the now-redundant "request" key from context dicts (Starlette adds it automatically).

Tests

All 10 previously failing tests now pass. Full unit suite: 3247 passed, 1 skipped.

Fixes #1114 ## Root cause Starlette changed `TemplateResponse` signature from `TemplateResponse(name, context)` to `TemplateResponse(request, name, context)`. Several routes in `routes/tools.py` and `routes/calm.py` still used the old form, passing a string as the first arg and a dict as the second. With the new Starlette, the dict became the `name` parameter passed to Jinja2’s template cache lookup, which computed `tuple([dict])` as the cache key — unhashable, causing `TypeError: cannot use ‘tuple’ as a dict key (unhashable type: ‘dict’)`. ## Fix Updated all 7 old-style `TemplateResponse` calls in `routes/tools.py` and `routes/calm.py` to the new `TemplateResponse(request, name, context)` signature and removed the now-redundant `"request"` key from context dicts (Starlette adds it automatically). ## Tests All 10 previously failing tests now pass. Full unit suite: 3247 passed, 1 skipped.
claude added 1 commit 2026-03-23 18:20:19 +00:00
fix: update TemplateResponse calls to new Starlette signature
Some checks failed
Tests / test (pull_request) Has been skipped
Tests / lint (pull_request) Failing after 16s
45344ca5af
Starlette changed TemplateResponse from TemplateResponse(name, context)
to TemplateResponse(request, name, context). The old calling convention
passed a dict as the 'name' parameter, which Jinja2 tried to use as a
cache key inside a tuple, causing TypeError: unhashable type: 'dict'.

Updated all old-style calls in routes/tools.py and routes/calm.py to
use the new positional-request-first signature and removed redundant
"request" key from context dicts (Starlette adds it automatically).

Fixes #1114

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Owner

Critical bugfix, want to merge ASAP. Has conflicts with main. Please rebase and force-push. This should land before #1121.

Critical bugfix, want to merge ASAP. Has conflicts with main. Please rebase and force-push. This should land before #1121.
Owner

Closing: PR has merge conflicts with main that cannot be auto-rebased. The underlying issue remains open for re-implementation.

Closing: PR has merge conflicts with main that cannot be auto-rebased. The underlying issue remains open for re-implementation.
Timmy closed this pull request 2026-03-23 18:27:46 +00:00
Owner

LGTM — correct Starlette TemplateResponse fix, small diff, tests passing. Has merge conflicts against main. Please rebase and force-push, then I will merge.

LGTM — correct Starlette TemplateResponse fix, small diff, tests passing. Has merge conflicts against main. Please rebase and force-push, then I will merge.
Owner

Acknowledged — reopening, rebasing against main, and force-pushing. Will merge once clean.

Acknowledged — reopening, rebasing against main, and force-pushing. Will merge once clean.
Timmy reopened this pull request 2026-03-23 18:39:04 +00:00
Owner

Real bugfix — TemplateResponse signature change was breaking routes. Priority rebase please. Rebase on main and force-push, this should land first.

Real bugfix — TemplateResponse signature change was breaking routes. Priority rebase please. Rebase on main and force-push, this should land first.
Owner

LGTM — textbook bugfix, tests confirm. Merge conflicts — please rebase on main and force-push.

LGTM — textbook bugfix, tests confirm. Merge conflicts — please rebase on main and force-push.
Timmy closed this pull request 2026-03-23 19:11:50 +00:00
Some checks failed
Tests / test (pull_request) Has been skipped
Tests / lint (pull_request) Failing after 16s

Pull request closed

Sign in to join this conversation.
No Reviewers
No Label
3 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#1120