question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Message mapping API does not return a failed future

See original GitHub issue

Maybe I do not understand the mapper endpoint feature added recently, so please bear with me 😃 I will close the issue once my doubt is clarified 😉

According to HttpBasedMessageMapping#mapMessage API docs, the method is supposed to returned

  1. a mapped message if the device payload can be successfully mapped to a new payload type OR
  2. a failed future, with a ServiceInvocationException, if the message cannot be mapped. This happens when the device registration info contains a mapper in its config but the adapter is not configured with an Endpoint corresponding to the configured mapper for the device/gateway

However, the current default implementation present with Hono does not do that. In the default impl., if a mapper is not configured for a device/gateway, or it is configured but endpoint is either missing or not configured for the adapter, then the original message is mapped as-is. No failure is returned. If this is the intended behavior, should the API docs be adapted accordingly?

If you look at where the API is used (i.e the onPublishedMessage handler of the MQTT adapter), I can see why the original message is mapped as-is instead of returning a failure (makes the caller code easier I think). IMHO, the mapper should not map all incoming MQTT messages: either it successfully maps an incoming message (if it can) or fails. In the case of a failure, the MQTT adapter can proceed to forward the message like before, ignoring the failed attempt to mapped the message.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:23 (23 by maintainers)

github_iconTop GitHub Comments

1reaction
BobClaerhoutcommented, Nov 10, 2020

great! Thanks @Alfusainey!

1reaction
sophokles73commented, Nov 10, 2020

@Alfusainey I have added the 1.5.0 release to the project management website.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Map the Exception of a failed Future - scala - Stack Overflow
If the Future succeeds with 1 , I'd like to keep that, however if it fails I would like to change the Exception...
Read more >
Future (Vert.x Stack - Docs 4.3.6 API)
Handles a failure of this Future by returning the result of another Future. If the mapper fails, then the returned future will be...
Read more >
Futures and Promises | Scala Documentation
A Future is a placeholder object for a value that may not yet exist. Generally, the value of the Future is supplied concurrently...
Read more >
Futures and error handling | Dart
Solution: Using Future.​​ If the callback returns a non-Future value, Future. sync() 's Future completes with that value. If the callback throws (as...
Read more >
How to Prevent the TypeError: Cannot Read Property Map of ...
Whether it's a display of data returned from an API or simply a drop-down list ... and what you can do to mitigate...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found