Skip to content

Commit ee459b0

Browse files
add message type in the response as per suggestion
1 parent 515ca53 commit ee459b0

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/aap_eda/wsapi/consumers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,13 @@ async def receive(self, text_data=None, bytes_data=None):
9090
data = json.loads(text_data)
9191
logger.debug(f"AnsibleRulebookConsumer received: {data}")
9292

93+
msg_type = data.get("type")
9394
try:
9495
msg_type = MessageType(data.get("type"))
9596
except ValueError:
9697
logger.error(f"Unsupported message type: {data}")
97-
await self.send('{"error": "unsupported message type"}')
98+
payload = {"error": f"unsupported message type: {msg_type}"}
99+
await self.send(text_data=json.dumps(payload))
98100
await self.close()
99101
return
100102

tests/integration/wsapi/test_consumer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ async def test_valid_websocket_route_wrong_type():
7878
await communicator.send_to(text_data='{"type": "unsuported_type"}')
7979
response = await communicator.receive_from()
8080
assert (
81-
response == '{"error": "unsupported message type"}'
81+
response == '{"error": "unsupported message type: unsuported_type"}'
8282
), "Unexpected error message"
8383
await communicator.disconnect()
8484

0 commit comments

Comments
 (0)