Skip to content

fix(core): rename parameter f to _f in _handle to prevent keyword argument collisions#897

Open
Hasnaathussain wants to merge 2 commits into
AnswerDotAI:mainfrom
Hasnaathussain:fix/834-wrapper-argument-f-collision
Open

fix(core): rename parameter f to _f in _handle to prevent keyword argument collisions#897
Hasnaathussain wants to merge 2 commits into
AnswerDotAI:mainfrom
Hasnaathussain:fix/834-wrapper-argument-f-collision

Conversation

@Hasnaathussain

@Hasnaathussain Hasnaathussain commented Jul 3, 2026

Copy link
Copy Markdown

What this PR does

When route handlers accept an argument named f (representing a file, form, or general parameter), invoking the handler via FastHTML's _handle function raises TypeError: _handle() got multiple values for argument 'f'.

This PR renames the parameter in _handle from f to _f (both in the source notebook nbs/api/00_core.ipynb and exported fasthtml/core.py) and integrates the regression test directly into the source notebook.

Fixes #894

Copilot AI review requested due to automatic review settings July 3, 2026 09:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a keyword-argument collision in FastHTML’s internal _handle wrapper that could raise TypeError: _handle() got multiple values for argument 'f' when a route handler accepts a parameter named f. It does so by renaming _handle’s first parameter to _f and adding a regression test in the source notebook.

Changes:

  • Rename _handle’s first parameter from f to _f to avoid collisions with injected request/form kwargs.
  • Add a regression test that posts form data with key f to a route whose handler signature includes f.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
nbs/api/00_core.ipynb Renames _handle argument and adds an in-notebook regression test reproducing the f kwarg collision scenario.
fasthtml/core.py Updates exported runtime implementation of _handle to use _f, preventing keyword collisions during handler invocation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread fasthtml/core.py
Comment on lines +279 to +280
async def _handle(_f, *args, **kwargs):
return (await _f(*args, **kwargs)) if is_async_callable(_f) else await run_in_threadpool(_f, *args, **kwargs)
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.

2 participants