eiffel-community / eiffel-remrem-publish

eiffel-remrem-publish
https://eiffel-community.github.io/eiffel-remrem-publish
Apache License 2.0
8 stars 77 forks source link

Publish to RabbitMQ fails if meta.source.domainId is too long - but NOT reported back to user #240

Closed e-pettersson-ericsson closed 2 years ago

e-pettersson-ericsson commented 2 years ago

Description

REMReM Publish does not include information in error response if the provided domain id is too. When I send an Eiffel event which has a too long domain id (that exceeds the RabbitMQ limit documented here ) it gives back a generic error which tells me nothing useful.

Response from REMReM Publish (HTTP code 500):

{
  "events": [
    {
      "id": "e7438f7c-85fd-437b-a153-cc77c31caeb1",
      "status_code": 500,
      "result": "Internal Server Error",
      "message": "RabbitMQ is down. Please try later"
    }
  ]
}

The logs however, contains the reason for the failure and should be propagated back to the user. Logs from REMReM Publish:

14-06-2022 09:49:04.132 [http-nio-8080-exec-3] ERROR c.e.e.r.p.s.MessageServiceRMQImpl.sendMessage - Short string too long; utf-8 encoded length = 293, max = 255.
java.lang.IllegalArgumentException: Short string too long; utf-8 encoded length = 293, max = 255.
    at com.rabbitmq.client.impl.ValueWriter.writeShortstr(ValueWriter.java:50)
    at com.rabbitmq.client.impl.MethodArgumentWriter.writeShortstr(MethodArgumentWriter.java:74)
    at com.rabbitmq.client.impl.AMQImpl$Basic$Publish.writeArgumentsTo(AMQImpl.java:2319)
    at com.rabbitmq.client.impl.Method.toFrame(Method.java:85)
    at com.rabbitmq.client.impl.AMQCommand.transmit(AMQCommand.java:104)
    at com.rabbitmq.client.impl.AMQChannel.quiescingTransmit(AMQChannel.java:396)
    at com.rabbitmq.client.impl.AMQChannel.transmit(AMQChannel.java:372)
    at com.rabbitmq.client.impl.ChannelN.basicPublish(ChannelN.java:690)
    at com.rabbitmq.client.impl.ChannelN.basicPublish(ChannelN.java:672)
    at com.rabbitmq.client.impl.ChannelN.basicPublish(ChannelN.java:662)
    at com.rabbitmq.client.impl.recovery.AutorecoveringChannel.basicPublish(AutorecoveringChannel.java:192)
    at com.ericsson.eiffel.remrem.publish.helper.RabbitMqProperties.send(RabbitMqProperties.java:427)
    at com.ericsson.eiffel.remrem.publish.helper.RMQHelper.send(RMQHelper.java:92)
    at com.ericsson.eiffel.remrem.publish.service.MessageServiceRMQImpl.sendMessage(MessageServiceRMQImpl.java:211)
    at com.ericsson.eiffel.remrem.publish.service.MessageServiceRMQImpl.send(MessageServiceRMQImpl.java:67)
    at com.ericsson.eiffel.remrem.publish.service.MessageServiceRMQImpl.send(MessageServiceRMQImpl.java:119)
    at com.ericsson.eiffel.remrem.publish.service.MessageServiceRMQImpl.send(MessageServiceRMQImpl.java:156)
    at com.ericsson.eiffel.remrem.publish.service.MessageServiceRMQImpl.send(MessageServiceRMQImpl.java:94)
    at com.ericsson.eiffel.remrem.publish.controller.ProducerController.generateAndPublish(ProducerController.java:205)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
.....

Motivation

It would be easier for the user to troubleshoot if the response states that it is a user input error instead of 'RabbitMQ being down'.

Exemplification

No vaidation is done by REMReM Generate on the provided domain id, and this might not be easily added either because REMReM Publish seem to add whatever domain id it is configured with to the provided domain and then the total amount of characters is known. Minimum fix for this issue is that REMReM Publish should return a proper error response, with 400 as the response code. Something like this:

HTTP code: 400
Message: The provided domain id exceeds the maximum of XX characters!

Benefits

Clear responses that are easy to understand and help with troubleshooting.

Possible Drawbacks

None that I can think of.

magnusbaeck commented 2 years ago

This is a duplicate of #172.

e-pettersson-ericsson commented 2 years ago

Indeed it is! I must have missed it. I'm Ok to close this issue if it will be taken care of in the linked issue :)