twisted / twisted/klein

200 OK / HTML content type / empty response body when returning None from a branch route

Open
#56 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

improvement
Dominant language
Python
Stars
838
Forks
123
Avg merge
7h 58m
Merged PRs (30d)
12

Description

In the following Klein application:

from klein import route, run

@route("/something", branch=True, strict_slashes=False)
def something(request):
    return None

run("localhost", 8080)

Then GET /something/else will result in a 200 OK with no content.

In fact, GET /something/ and GET /something have the same behavior, unless you set strict_slashes=True, in which case only GET /something/ will return a 404 (GET /something/else and GET /something still return 200s even with strict_slashes=True).

This seems off to me; a None ought to be 404s all around.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the minimal Python Klein application in the issue and requesting /something, /something/, and /something/else with both strict_slashes settings. Read the branch-route handling responsible for None responses and add regression coverage; done means these unmatched requests consistently return 404 rather than 200 with an empty body.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.