pelias / pelias/api

Text input with leading slash can cause unexpected 400 errors

Open
#1,584 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

An interesting report came in today, some short autocomplete queries return an unexpected 400 error with a leading slash (/).

Some examples that are broken:

/v1/autocomplete?text=/cali
/v1/autocomplete?text=/colo
/v1/autocomplete?text=/brook

Some examples that work:

/v1/autocomplete?text=/broo
/v1/autocomplete?text=/asdf

In all broken cases, the parsed_text.subject property is just the slash:

"query": {
      "text": "/brook",
      "parser": "pelias",
      "parsed_text": {
        "subject": "/",
        "locality": "brook",
        "admin": "brook"
      },

It looks like whether or not the input was parsed as a subject will determine if this bug manifests or not, but maybe we want to fix it elsewhere, like by removing leading slashes?

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 at the autocomplete API entry point and trace how a leading slash becomes parsed_text.subject and can produce a 400 response. Reproduce the linked /cali, /colo, and /brook examples alongside the working cases; done means leading-slash autocomplete queries no longer fail unexpectedly and parsing remains correct.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.