Skip to content

Commit dee64db

Browse files
Fixed PR comments raised from copilot
1 parent 7566046 commit dee64db

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

contentstack/entry.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -208,16 +208,13 @@ def _impl_live_preview(self):
208208
def _merged_response(self):
209209
if 'entry_response' in self.http_instance.live_preview and 'lp_response' in self.http_instance.live_preview:
210210
entry_response = self.http_instance.live_preview['entry_response']
211-
lp_response = self.http_instance.live_preview['lp_response']
212-
213211
# Ensure lp_entry exists
214-
if 'entry' in lp_response:
215-
lp_entry = lp_response['entry']
212+
if 'entry' in self.http_instance.live_preview.get('lp_response', {}):
213+
lp_entry = self.http_instance.live_preview['lp_response']['entry']
216214
else:
217-
raise KeyError(f"'entry' key not found in lp_response: {lp_response}")
218-
# 🛠️ Fix: Ensure both are lists of dictionaries
215+
lp_entry = {}
219216
if not isinstance(entry_response, list):
220-
entry_response = [entry_response] # Wrap in a list if it's a dict
217+
entry_response = [entry_response]
221218
if not isinstance(lp_entry, list):
222219
lp_entry = [lp_entry] # Wrap in a list if it's a dict
223220
if not all(isinstance(item, dict) for item in entry_response):

contentstack/query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ def _impl_live_preview(self):
355355

356356
if lp_resp and 'error_code' not in lp_resp:
357357
if 'entry' in lp_resp:
358-
self.http_instance.live_preview['lp_response'] = lp_resp['entry'] # Extract entry
358+
self.http_instance.live_preview['lp_response'] = {'entry': lp_resp['entry']} # Extract entry
359359
else:
360360
print(f"Warning: Missing 'entry' key in lp_response: {lp_resp}")
361361
return None

0 commit comments

Comments
 (0)