GSMA-CPAS / BWRP-common-adapter

The "Layer 2.5" with all Common functionality APIs
Apache License 2.0
2 stars 0 forks source link

Response erroring out when RAW format is selected in get contracts by id #28

Closed sudo-tilakvardhan closed 3 years ago

sudo-tilakvardhan commented 3 years ago

While testing "get contracts by id" endpoint and hitting {{baseUrl}}/contracts/:contractId?format=RAW

I get http response 422 with following message

{ "internalErrorCode": 2002, "message": "Unvailable RAW format", "description": "The RAW format of this contract is unavailable." }

This works as expected when requesting JSON format

zkong-gsma commented 3 years ago

Is this while the contract is in "DRAFT" mode?

If yes, then its an expected result.

RAW will only be available after "SENT"/"RECEIVED"

sudo-tilakvardhan commented 3 years ago

Yes first this was tested in DRAFT mode.

But Two additional observation: 1.) Even if I get a contract in raw which is of SENT mode, I get 500 error code with response Cannot read property 'name' of undefined 2.) If RAW isn't supported in DRAFT mode, we need to update the error msg when a user request in any other format. Current msg is : "message": "request.query.format should be equal to one of the allowed values: JSON, RAW"

zkong-gsma commented 3 years ago

1) "name" is probably a bug that need fixing. "name" was removed from the code from the other requirements. we might have missed out somewhere.

2) eventually yes, once we finished focus on the Main Positive used case. currently we are focus on delivering the main usecase. these can be put into a "list" of to do in future for a cleaner setup.

csarthou commented 3 years ago
  1. I agree with Kong. After a quick verification on the return mapping, no name should be returned in RAW format.

  2. This error "message": "request.query.format should be equal to one of the allowed values: JSON, RAW" is delivered during API schema validation of the incoming request ( the allowed values are only JSON or RAW ). This request is rejected because it does not satisfy the API interface. This request will never be acceptable. And if this error happened on the UI, the UI source code should be modified. But the error with internalErrorCode 2002 is an error for an incompatibility between a request and the actual state of the contract object. This request is well formated, and will be acceptable when the contract object will be in a compatible state. The meaning of these 2 errors is not really the same.

sudo-tilakvardhan commented 3 years ago

Closing as it works after updating the common-adapter to latest version.