Skip to content

Commit e4c996b

Browse files
committed
more feedback
1 parent 15800b9 commit e4c996b

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

ldclient/impl/datasourcev2/polling.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,9 @@ def polling_payload_to_changeset(data: dict) -> _Result[ChangeSet, str]:
231231
if not isinstance(event, dict):
232232
return _Fail(error="Invalid payload: 'events' must be a list of objects")
233233

234-
for event in data["events"]:
234+
if "event" not in event:
235+
continue
236+
235237
if event["event"] == EventName.SERVER_INTENT:
236238
try:
237239
server_intent = ServerIntent.from_dict(event["data"])

ldclient/impl/datasystem/protocolv2.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,17 @@ def from_dict(data: dict) -> "Payload":
113113
"""
114114
Create a Payload from a dictionary representation.
115115
"""
116+
intent_code = data.get("intentCode")
117+
118+
if intent_code is None or not isinstance(intent_code, str):
119+
raise ValueError(
120+
"Invalid data for Payload: 'intentCode' key is missing or not a string"
121+
)
122+
116123
return Payload(
117124
id=data.get("id", ""),
118125
target=data.get("target", 0),
119-
code=IntentCode(data.get("intentCode")),
126+
code=IntentCode(intent_code),
120127
reason=data.get("reason", ""),
121128
)
122129

0 commit comments

Comments
 (0)