Skip to content

Commit 32ac491

Browse files
committed
Add defensive null check for response.data
Guard against unexpected None data in non-304 responses to prevent TypeError when accessing dictionary keys.
1 parent 17fee2e commit 32ac491

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

posthog/client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,6 +1199,12 @@ def _load_feature_flags(self):
11991199
self._last_feature_flag_poll = datetime.now(tz=tzutc())
12001200
return
12011201

1202+
if response.data is None:
1203+
self.log.error(
1204+
"[FEATURE FLAGS] Unexpected empty response data in non-304 response"
1205+
)
1206+
return
1207+
12021208
self.feature_flags = response.data["flags"] or []
12031209
self.group_type_mapping = response.data["group_type_mapping"] or {}
12041210
self.cohorts = response.data["cohorts"] or {}

0 commit comments

Comments
 (0)