aws / aws/aws-iot-device-sdk-python-v2

Better error description when calling a subscribe on SubscribeToTopicRequest without a topic specified

Open
#247 1 comment 0 reactions 0 assignees View on GitHub
feature-request p2
Dominant language
Python
Stars
446
Forks
228
Avg merge
17h 31m
Merged PRs (30d)
1

Description

**Is your feature request related to a problem? Please describe.**
I made a mistake by subscribing to a topic but specifying a wrong data member as the topic

```
responserequest = SubscribeToTopicRequest()
responserequest.topic_name = "$aws/things/mythingname/shadow/name/streamcontrol/update/delta"
g_shadow_handler = shadow_delta_handler()
g_delta_subscribe_operation = g_ipc_client.new_subscribe_to_topic(g_shadow_handler)
future = g_delta_subscribe_operation.activate(responserequest)
future.result()
```

notice my mistake by using **topic_name** instead of **topic**

because of the flexibility of python i didn't see any error when specifying topic_name which is not a member of the SubscribeToTopicRequest class.

The error i did see in the greengrass.log was :

```
2021-10-29T01:45:08.264Z https://forums.aws.amazon.com/ (Thread-6) software.amazon.awssdk.eventstreamrpc.ServiceOperationMappingContinuationHandler: Sending connect response for au.com.mtdata.smartdvr.gg_shadow_config. {}
2021-10-29T01:45:08.267Z https://forums.aws.amazon.com/ (Thread-6) com.aws.greengrass.ipc.common.ExceptionUtil: Unhandled exception in IPC. {}
java.lang.NullPointerException
at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1690)
at com.aws.greengrass.builtin.services.pubsub.PubSubIPCEventStreamAgent.handleSubscribeToTopicRequest(PubSubIPCEventStreamAgent.java:160)
at com.aws.greengrass.builtin.services.pubsub.PubSubIPCEventStreamAgent.access$300(PubSubIPCEventStreamAgent.java:45)
at com.aws.greengrass.builtin.services.pubsub.PubSubIPCEventStreamAgent$SubscribeToTopicOperationHandler.lambda$handleRequest$1(PubSubIPCEventStreamAgent.java:237)
at com.aws.greengrass.ipc.common.ExceptionUtil.translateExceptions(ExceptionUtil.java:33)
at com.aws.greengrass.builtin.services.pubsub.PubSubIPCEventStreamAgent$SubscribeToTopicOperationHandler.handleRequest(PubSubIPCEventStreamAgent.java:230)
at com.aws.greengrass.builtin.services.pubsub.PubSubIPCEventStreamAgent$SubscribeToTopicOperationHandler.handleRequest(PubSubIPCEventStreamAgent.java:209)
at software.amazon.awssdk.eventstreamrpc.OperationContinuationHandler.onContinuationMessage(OperationContinuationHandler.java:271)
at software.amazon.awssdk.crt.eventstream.ServerConnectionContinuationHandler.onContinuationMessageShim(ServerConnectionContinuationHandler.java:53)

2021-10-29T01:45:08.270Z https://forums.aws.amazon.com/ (Thread-6) software.amazon.awssdk.eventstreamrpc.RpcServer: New connection code https://forums.aws.amazon.com/ for https://forums.aws.amazon.com/(2021-10-29T01:45:08.270133Z) - . {}
2021-10-29T01:45:08.272Z https://forums.aws.amazon.com/ (Thread-6) software.amazon.awssdk.eventstreamrpc.ServiceOperationMappingContinuationHandler: aws.greengrass#GreengrassCoreIPC authenticated identity: au.com.mtdata.smartdvr.gg_shadow_config. {}

```
which is not very helpful to find and resolve the issue

**Describe the solution you'd like**
When subscribing using SubscribeToTopicRequest and there is no topic specified, perhaps have a clear message saying
"_Can't subscribe as no topic has been specified_"

**Describe alternatives you've considered**
The alternative is to follow the API from the start.. which is fully on me

**Additional context**
The original issue that lead to this issue being raised : https://forums.aws.amazon.com/thread.jspa?messageID=999711󴄟

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.