playframework / playframework/playframework

When you cannot match a type in routes file, return 404 rather than 400

Open
#9,668 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

type:improvement
Dominant language
Scala
Stars
12.6k
Forks
4k
Avg merge
2d 3h
Merged PRs (30d)
29

Description

I have this route:

GET      /player/proxy/:what       controllers.Player.proxy(what: Char)

If I want to pass more than 1 character for :what, I get this response:

(400,Cannot parse parameter what with value '3a' as Char: what must be exactly one digit in length.)

It would make much more sense to consider the route unmatched, continue traversing the rest of the routes, and return 404 at the end if nothing matches.

I would also like to hear everyone's opinions.

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 tracing route matching and typed parameter parsing for the route shown in the issue. Check how a failed Char conversion is classified and whether matching can continue to later routes. Done means an overlong value does not produce a 400 from this route and instead reaches a matching route or ends as a 404.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.