Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safefields doesn't work with "array of errors" #45

Closed
loopdtw opened this issue Feb 14, 2017 · 4 comments · Fixed by #73
Closed

Safefields doesn't work with "array of errors" #45

loopdtw opened this issue Feb 14, 2017 · 4 comments · Fixed by #73

Comments

@loopdtw
Copy link

loopdtw commented Feb 14, 2017

Description of feature (or steps to reproduce if bug)

Using loopback as an example, we can call POST with /users with an array of objects repeatedly such as below

[
  {
    "id": 1,
    "firstname": "Allen"
  },
  {
    "id": 2,
    "firstname": "Bob"
  }
]

with this middleware config:

"final:after": {
        "strong-error-handler": {
            "params": {
                "log": false,
                "safeFields": ["name", "message", "details"]
            }
        }
    }

Expected result

{
  "error": {
    "statusCode": 500,
    "name": "ArrayOfErrors",
    "message": "Failed with multiple errors, see `details` for more information.",
    "details": [
      {
        "name": "Error",
        "message": "ER_DUP_ENTRY: Duplicate entry '2' for key 'PRIMARY'",
        "code": "ER_DUP_ENTRY",
        "errno": 1062,
        "sqlState": "23000",
        "index": 0
      },
      {
        "name": "Error",
        "message": "ER_DUP_ENTRY: Duplicate entry '3' for key 'PRIMARY'",
        "code": "ER_DUP_ENTRY",
        "errno": 1062,
        "sqlState": "23000",
        "index": 0,
      }
    ]
  }
}

Actual result (if bug)

{
  "error": {
    "statusCode": 500
  }
}

Additional information (Node.js version, LoopBack version, etc)

"loopback": "^3.0.0",
"strong-error-handler": "^1.0.1"

@SynerG
Copy link

SynerG commented Feb 22, 2017

Just in case, version 1.0.1 did not yet implement the 'safeFields' feature. So check that you really have a suitable version installed (version 1.2.1 includes the 'safeFields' feature).
I haven't checked if this issue actually happens in 1.2.1 though.

@bajtos bajtos added the bug label Mar 13, 2017
@bajtos
Copy link
Member

bajtos commented Mar 13, 2017

Hello, I agree this is a bug. I am afraid we don't have bandwidth to fix it ourself in the near future, would you like to contribute the patch yourself?

@IgorVanian
Copy link

2.2.0 not working aswell

@dhmlau
Copy link
Member

dhmlau commented May 29, 2018

See also: #40 and strongloop/loopback#3356

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants