Troubleshooting
Requirements
As part of the project it is necessary to have a way to see the errors that have occurred both when sending the orders to Narvar and when creating the returns in Hybris
Proposal
For errors in Hybris when creating a Narvar return, use the same process as when the order process fails. In this way, whenever an error occurs, an email will be sent to orderissues@rapha.cc with the origin payload and the error produced. Currently there is an integration in JIRA that creates a ticket for each of these emails so we can use the ticket as a historical record of the actions done for the error.
For errors when sending the orders to Narvar create a Grafana dashboard so we can see all of them in the same place.
Errors creating return requests
Narvar sends to Hybris three different events for each RMA, return_initiated_standard, return_on_its_way_standard and return_delivered_standard. These are the common errors we are sending for each one.
return_initiated_standard
When this event is received, a new return request is created in Hybris. The error in this case is usually NotReturnableException: Not enough entries to return. because the product is not returnable in Hybris. The main causes are
- There is already a return request created for that product through CS cockpit. To check this, edit the order in HMC, access the Administration tab and look for the Return Request list. Editing each return request you can check the associated product and if it has Narvar number or not

- The product is not returnable in Hybris. To check this, edit the order in HMC, go to the Consignments tab and edit the consignment. For each entry, in the Administration tab you can see the value of the refundable check. A product may be non-refundable because it was never actually shipped (shippedquantity in consignment entry is 0) or because CS created a discretionary refund marking it as non-refundable.

return_on_its_way_standard and return_delivered_standard
When this event is received, the return request is updated in Hybris. The error in this case is usually ReturnRequestNotFoundException: Return request not found because the RMA does not exist in Hybris. The cause of this is that the return_initiated_standard failed at first so the return request was never created in Hybris.
Errors sending orders to Narvar
Grafana dashboard is available in https://rapharacing.grafana.net/d/F3zXWio4z/orders-prod?orgId=1. The following panels are included in the dashboard
- Orders coming to MW: this table shows some fields of the orders being sent to Narvar
- Error Responses when sending orders to Narvar: this shows all the errors on the lambda narvar-prod-narvar-order-process
- Validation Error Responses when sending orders to Narvar: this shows the validation errors on the lambda narvar-prod-narvar-order-process in a more friendly way than the previous panel
- RMA requests received in Narvar API Gateway: this shows all the events coming from Narvar
- Errors when creating RMA's on Hybris: this shows errors on Hybris when trying to create the return request. All of those are sent to orderissues email as well
- Unhandled errors when creating RMA's on Hybris: this shows unhandled errors on Hybris. The objective of this panel is to show all the errors in Hybris to be sure we log everything, not only the ones managed
- OK Responses when creating orders in Narvar: this shows all the successful responses from Narvar when sending orders
- TraceId - RequestId: this shows the data about the requests on the lambda narvar-prod-narvar-order-process