hasura / hasura/graphql-engine
REST API Calls (GET) fail when "/" (forward slash) is part of the query (key) string
- Dominant language
- TypeScript
- Stars
- 32.1k
- Forks
- 3k
- PR merge metrics
- PR metrics pending
Description
### Version Information
Server Version: 2.8.1
### Environment
Cloud
### What is the expected behaviour?
RESTified endpoints should support and correctly parse strings with "/" in it.
### Keywords
REST API, Query Param
### What is the current behaviour?
When a "/" is part of the query param in a REST (GET) API, it results in the following error messages:
**Error Message: The endpoint does not exist
Error Status code: 404**
### How to reproduce the issue?
1. Create a Hasura cloud project and add a database.
2. Create and track table with a String field type:
```
CREATE TABLE api_test
(
id int NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
locationKey TEXT,
locationName TEXT
);
```
3. INSERT Some test values into the table:
```
INSERT INTO api_test(locationKey, locationName) values ('us-west-1', 'US West #1');
INSERT INTO api_test(locationKey, locationName) values ('us-west-2', 'US West #2');
INSERT INTO api_test(locationKey, locationName) values ('us-east/3', 'US East #3'); -- locationKey has a slash
```
4. Create a [RESTified Graphql endpoint](https://hasura.io/docs/latest/graphql/core/api-reference/restified/) using this table with an argument for locationKey, for example using this query:
```
query MyQuery2 ($loc_id: String!) {
api_test(where: {locationKey: {_eq: $loc_id}}) {
id
locationKey
locationName
}
}
```
5. Configure the endpoint to accept GET requests and test it with loc_id **("us-east/3").**

6. Run the Request. Observe the following error:

### Any possible solutions?
The loc_id is parsed correctly if passed in the request body of a POST API call.
Contributor guide
Research direction
Reproduce the RESTified GET endpoint described in the issue with the loc_id value "us-east/3", then compare it with the POST behavior, which reportedly parses the value correctly. Trace the REST API query-parameter and path parsing entry point; done means GET requests accept slash-containing query values instead of returning a 404 endpoint error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, postgres
- Domain
- api, backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100