Skip to content

/GET /users/me triggers handler for /GET /users/:objectId as well #2933

Closed
@zaach

Description

@zaach

/GET /users/me matches two routes because of the overlap with /GET /users/:objectId. The second handler is called with the objectId set to me, which fails with a "Object not found." error.

Steps to reproduce

  1. Turn on verbose logging.
  2. create session
  3. curl -X GET /users/me (with necessary headers)

Expected Results

There should only be one request logged, and no "Object not found." error.

Actual Outcome

Two separate logs for verbose: REQUEST for [GET] /parse/1/users/me, an "Object not found." ParseError, and an express.js error Error: Can't set headers after they are sent.

Environment Setup

parse-server 2.2.23 locally and on AWS

Logs/Trace

2016-10-25T06:25:52Z parse:RTWTPIYXJKL/4d7370c0c344 error: Error generating response. ParseError { code: 101, message: 'Object not found.' } code=101, message=Object not found.
2016-10-25T06:25:52Z parse:RTWTPIYXJKL/4d7370c0c344 Tue, 25 Oct 2016 06:25:52 GMT express:router handleParseErrors  : /parse/1/users/me
2016-10-25T06:25:52Z parse:RTWTPIYXJKL/4d7370c0c344     at next (/app/node_modules/express/lib/router/index.js:271:10)
2016-10-25T06:25:52Z parse:RTWTPIYXJKL/4d7370c0c344 Error: Can't set headers after they are sent.
2016-10-25T06:25:52Z parse:RTWTPIYXJKL/4d7370c0c344     at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:356:11)
2016-10-25T06:25:52Z parse:RTWTPIYXJKL/4d7370c0c344     at ServerResponse.header (/app/node_modules/express/lib/response.js:719:10)
2016-10-25T06:25:52Z parse:RTWTPIYXJKL/4d7370c0c344     at ServerResponse.send (/app/node_modules/express/lib/response.js:164:12)
2016-10-25T06:25:52Z parse:RTWTPIYXJKL/4d7370c0c344     at ServerResponse.json (/app/node_modules/express/lib/response.js:250:15)
2016-10-25T06:25:52Z parse:RTWTPIYXJKL/4d7370c0c344     at handleParseErrors (/app/node_modules/parse-server/lib/middlewares.js:248:9)
2016-10-25T06:25:52Z parse:RTWTPIYXJKL/4d7370c0c344     at Layer.handle_error (/app/node_modules/express/lib/router/layer.js:71:5)
2016-10-25T06:25:52Z parse:RTWTPIYXJKL/4d7370c0c344     at /app/node_modules/express/lib/router/index.js:280:7
2016-10-25T06:25:52Z parse:RTWTPIYXJKL/4d7370c0c344     at Function.process_params (/app/node_modules/express/lib/router/index.js:330:12)
2016-10-25T06:25:52Z parse:RTWTPIYXJKL/4d7370c0c344     at trim_prefix (/app/node_modules/express/lib/router/index.js:310:13)

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