NIS API error mapping improvement

Hello!

I’ve been reading and testing the NIS API and I’ve found some strange behavior with the error mapping.

First case

When the deadline field is before the timestamp the API returns a 200 HTTP Code but the message contains an error description "FAILURE_PAST_DEADLINE".

In addiction, the message contains the transactionHash field, which it will never included in the blockchain (as expected).

The expected HTTP code should be 4XX.

Second case

The request body doesn’t contains the fee field, or the type isn’t a number, it returns a 500 HTTP Code.

The expected HTTP code should be 4XX.

Third case

The public key and private key don’t match, the NIS response is an 200 HTTP code with the error inside (FAILURE_SIGNATURE_NOT_VERIFIABLE).

The expected HTTP code should be 4XX.

Fourth case

When the request contains a bad value for type field (9898), it returns correctly a 400 BAD REQUEST.

It’s the expected behavior.


The unexpected behaviour in the error mapping forces developers to override the error mapping manualy. They cannot use the predefined logic that the HTTP Libraries contains.

I’m aware that a change right now could break everything, but I believe that it could be addressed with Catapult, do I?

Best,

3 Likes

Haven’t noticed that. Will take a look at it on weekend.

1 Like