Skip to content
This repository has been archived by the owner on Oct 21, 2020. It is now read-only.

Handle invalid JSON #175

Closed
ojongerius opened this issue May 18, 2018 · 1 comment
Closed

Handle invalid JSON #175

ojongerius opened this issue May 18, 2018 · 1 comment

Comments

@ojongerius
Copy link
Contributor

In AWS I see a 502 with "Internal Server error".

Logs show Unexpected token _ in JSON at position 1

Reproduce:

▶ curl -XPOST -H 'Content-Type:application/graphql'  -d '{__schema { queryType { name, fields { name, description} }}}' https://hxtsoafqna.execute-api.us-east-1.amazonaws.com/stage/graphql
{"message": "Internal server error"}%

I guess we need to validate the payload before we continue.

Related: #174

@user512
Copy link
Contributor

user512 commented Jan 6, 2019

👋 @ojongerius, I took a look at this issue, I was wondering if it's a good idea to check valid JSON or empty body inside this try block?

open-api/src/handler.js

Lines 60 to 68 in dc7f111

try {
await connectToDatabase();
} catch (err) {
log('MongoDB connection error: ', err);
// TODO: return 500?
/* eslint-disable no-process-exit */
process.exit();
/* eslint-enable no-process-exit */
}

user512 added a commit to user512/open-api that referenced this issue Jan 11, 2019
raisedadead pushed a commit that referenced this issue Jan 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants