lodestar icon indicating copy to clipboard operation
lodestar copied to clipboard

Multiple API errors are not spec compliant

Open nflaig opened this issue 1 year ago • 2 comments

Describe the bug

The beacon API spec notes that multiple API errors (e.g submitPoolAttestations) should return a 400 error with details of each failure.

If one or more attestations fail validation the node MUST return a 400 error with details of which attestations have failed, and why.

There was initial work on this to handle multiple errors (https://github.com/ChainSafe/lodestar/pull/2595), we just need to update the response format and status code.

Expected behavior

The response should be formatted like this

{
  "code": 400,
  "message": "some failures",
  "failures": [
    {
      "index": 3,
      "message": "invalid signature"
    }
  ]
}

and return 400 http status code instead of 500

Steps to reproduce

Call any API that accepts an array of objects with invalid data.

Additional context

  • https://github.com/ChainSafe/lodestar/pull/2595

Operating system

Linux

Lodestar version or commit hash

098d35aa0f5afc351a131b8a1e88485907985226

nflaig avatar Jan 14 '24 11:01 nflaig

@nflaig Can I take this on?

har777 avatar Feb 25 '24 06:02 har777

  • Related https://github.com/ChainSafe/lodestar/issues/6480

nflaig avatar Feb 25 '24 19:02 nflaig