Skip to content

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

@loopdtw

Description

@loopdtw

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"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions