Skip to content

Incorrect response for "Object not found" on 4.2.0 #7386

Closed
@saulogt

Description

@saulogt

New Issue Checklist

Issue Description

After upgrading Parse server to version 4.2.0, a status code response that should be 404 is 500 instead. The previous version (4.1.0) works as expected.

Steps to reproduce

Install parse server 4.2.0 or newer

const api = new ParseServer({
  databaseURI: 'mongodb://localhost:27017/dev', // Connection string for your MongoDB database
  // cloud: './cloud/main.js', // Path to your Cloud Code
  appId: 'myAppId',
  masterKey: 'myMasterKey', // Keep this key secret!
  fileKey: 'optionalFileKey',
  serverURL: 'http://localhost:1337/parse', // Don't forget to change to https if needed
  enableExpressErrorHandler: true, /// <<< This seems to be the issue
});
  
app.use('/parse', api);

/// Error handler
app.use((e, req, res, next) => {
  console.log(e);
  next(e, req, res);
})


app.listen(1337, function() {
  console.log('parse-server-example running on port 1337.');
});
  

Try to get a non existing user:

curl --request GET \
  --url http://localhost:1337/parse/classes/_User/CsXUw1MRCe \
  --header 'x-parse-application-id: <APPID>'

Actual Outcome

< HTTP/1.1 500 Internal Server Error
< X-Powered-By: Express
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: GET,PUT,POST,DELETE,OPTIONS
< Access-Control-Allow-Headers: X-Parse-Master-Key, X-Parse-REST-API-Key, X-Parse-Javascript-Key, X-Parse-Application-Id, X-Parse-Client-Version, X-Parse-Session-Token, X-Requested-With, X-Parse-Revocable-Session, Content-Type, Pragma, Cache-Control
< Access-Control-Expose-Headers: X-Parse-Job-Status-Id, X-Parse-Push-Status-Id
< Content-Security-Policy: default-src 'none'
< X-Content-Type-Options: nosniff
< Content-Type: text/html; charset=utf-8
< Content-Length: 415
< Date: Wed, 12 May 2021 22:40:21 GMT
< Connection: keep-alive
< Keep-Alive: timeout=5
<
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>ParseError: Object not found.<br> &nbsp; &nbsp;at /Users/xyz/work/is-parse-server/node_modules/parse-server/src/Routers/ClassesRouter.js:97:17<br> &nbsp; &nbsp;at runMicrotasks (&lt;anonymous&gt;)<br> &nbsp; &nbsp;at processTicksAndRejections (internal/process/task_queues.js:93:5)</pre>
</body>
</html>

Expected Outcome

< HTTP/1.1 404 Not Found
< X-Powered-By: Express
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: GET,PUT,POST,DELETE,OPTIONS
< Access-Control-Allow-Headers: X-Parse-Master-Key, X-Parse-REST-API-Key, X-Parse-Javascript-Key, X-Parse-Application-Id, X-Parse-Client-Version, X-Parse-Session-Token, X-Requested-With, X-Parse-Revocable-Session, Content-Type, Pragma, Cache-Control
< Access-Control-Expose-Headers: X-Parse-Job-Status-Id, X-Parse-Push-Status-Id
< Content-Type: application/json; charset=utf-8
< Content-Length: 40
< ETag: W/"28-+5YirrDDOrWkX+4BB7U4IKOPrA0"
< Date: Wed, 12 May 2021 22:28:40 GMT
< Connection: keep-alive
< Keep-Alive: timeout=5
<
* Connection #0 to host localhost left intact
{"code":101,"error":"Object not found."}* Closing connection 0

Failing Test Case / Pull Request

  • 🤩 I submitted a PR with a fix and a test case.
  • 🧐 I submitted a PR with a failing test case.

Environment

Server

  • Parse Server version: 4.2.0
  • Operating system: macos and linux
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): Localhost and Heroku

Database

  • System (MongoDB or Postgres): Mongodb
  • Database version: 4.0
  • Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc): MongoDb Atlas

Client

  • SDK (iOS, Android, JavaScript, PHP, Unity, etc): javascript (node) and rest api
  • SDK version: 2.12

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions