pelias / pelias/api

Using Invalid Method Should Return 405

Open
#1,100 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
259
Forks
168
Avg merge
6h 15m
Merged PRs (30d)
1

Description

When accessing some endpoints, it appears that only GET, OPTIONS and HEAD are appropriate HTTP Request Methods. If an invalid HTTP Request Method is used, the response is coded as 404 Not Found, but should be 405 Method Not Allowed.

To Reproduce:

  1. Send a GET to /search/structured?locality=foo (200 OK returned)
  2. Send a POST to that same URL.

Expected Response:
Server should respond with a 405 Method Not Allowed, with an appropriate message in the response body.
Actual Response:
404 Not Found

{
    "error": "not found: invalid path"
}

Additional Information:
Endpoints I've seen with this behavior:

  • /
  • /search (a POST actually returns a 200 OK here)
  • /autocomplete
  • /search/structured
  • /place
  • /reverse

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 reproducing the GET and POST requests for /search/structured?locality=foo, then inspect the request handling for the listed endpoints: /, /search, /autocomplete, /search/structured, /place, and /reverse. Done means unsupported methods return 405 Method Not Allowed with an appropriate response body instead of 404, while supported methods continue to work.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.