Skip to content

fix(server): accept the routed path in the index view - #545

Open
Eljees wants to merge 1 commit into
infobyte:masterfrom
Eljees:fix/index-view-kwargs-543
Open

fix(server): accept the routed path in the index view#545
Eljees wants to merge 1 commit into
infobyte:masterfrom
Eljees:fix/index-view-kwargs-543

Conversation

@Eljees

@Eljees Eljees commented Jul 28, 2026

Copy link
Copy Markdown

Fixes #543

GET / returns HTTP 500 on a fresh install because the view function and its routes disagree:

@app.errorhandler(404)
@app.route('/', defaults={'text': ''})
@app.route('/<path:text>')
def index(ex):

Both routes supply text, and the error handler supplies ex, so Flask always calls index() with a keyword the signature doesn't accept:

TypeError: create_app.<locals>.index() got an unexpected keyword argument 'text'

This is the same one-line change that PR #537 made and that was lost when master was re-synced (see #543 for the archaeology; #541 was closed with a workaround that no longer helps, because master itself is broken).

Reproduced before and after

Minimal Flask app with exactly these decorators, python:3.12 / Flask 3:

master      GET /      -> 500
master      GET /a/b   -> 500
master      raises     -> TypeError: index() got an unexpected keyword argument 'text'
with fix    GET /      -> 200
with fix    GET /a/b   -> 200

ex=None, text=None keeps every existing caller working: the 404 handler still passes the exception, both routes still pass the captured path, and the body of the function is unchanged.

One note from the issue that is worth acting on separately: the fix needs to land on whichever internal branch master is synced from, otherwise it will be dropped again the next time.

AI-assisted (LLM used for drafting); the reproduction above was run and verified by me.

Both catch-all routes pass 'text' and the 404 handler passes 'ex', so every request to '/' raised TypeError and returned HTTP 500. Restores the signature from PR infobyte#537.

Signed-off-by: Eljees <3.14hell@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.

The fix from PR #537 was lost from master

1 participant