Skip to content

Commit 1ad5b3e

Browse files
committed
Respond to unknown actions with error and message
1 parent acc6109 commit 1ad5b3e

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

src/relay_listener.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ def process_action(self, payload: dict):
107107
elif action_name == "worklist.update_status":
108108
return UpdateWorklistItemStatus(self.storage).call(payload)
109109
else:
110-
raise ValueError(f"Unsupported action: {action_name}")
110+
logger.error("Unsupported action: %s", action_name)
111+
return {"status": "error", "message": f"Unsupported action: {action_name}"}
111112

112113
def _connect(self):
113114
"""Connect to Azure Relay."""

tests/test_relay_listener.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,13 @@ def test_process_action_invalid_type(self, storage_instance, listener_payload):
159159

160160
listener_payload["action_type"] = "worklist.unknown_action"
161161

162-
with pytest.raises(ValueError):
163-
response = subject.process_action(listener_payload)
164-
assert response == {
165-
"status": "error",
166-
"action_id": "action-12345",
167-
"error": "Unknown action type: worklist.unknown_action",
168-
}
169-
170-
storage_instance.store_worklist_item.assert_not_called()
162+
response = subject.process_action(listener_payload)
163+
assert response == {
164+
"status": "error",
165+
"message": "Unsupported action: worklist.unknown_action",
166+
}
167+
168+
storage_instance.store_worklist_item.assert_not_called()
171169

172170

173171
class TestRelayURIWithDefaultAzureCredential:

0 commit comments

Comments
 (0)