jebin2 commited on
Commit
361c3a2
·
1 Parent(s): 8b062ce

feat: fetch and log detailed Instagram container processing errors

Browse files
social_media_publishers/instagram/publisher.py CHANGED
@@ -221,22 +221,24 @@ class InstagramPublisher(SocialPublisher):
221
  """Poll container status until ready or failed."""
222
  endpoint = f"{self.api_base}/{container_id}"
223
  logger.info("⏳ Waiting for processing...")
224
-
225
  for attempt in range(1, max_attempts + 1):
226
- params = {'access_token': self.access_token, 'fields': 'status_code'}
227
  response = self._get_session().get(endpoint, params=params)
228
  result = response.json()
229
-
230
  status = result.get('status_code')
231
  logger.debug(f" Attempt {attempt}/{max_attempts}: {status}")
232
-
233
  if status == 'FINISHED':
234
  return status
235
  elif status == 'ERROR':
 
 
236
  return status
237
-
238
  time.sleep(10)
239
-
240
  return 'TIMEOUT'
241
 
242
  def _publish_container(self, container_id: str) -> Dict[str, Any]:
 
221
  """Poll container status until ready or failed."""
222
  endpoint = f"{self.api_base}/{container_id}"
223
  logger.info("⏳ Waiting for processing...")
224
+
225
  for attempt in range(1, max_attempts + 1):
226
+ params = {'access_token': self.access_token, 'fields': 'status_code,status'}
227
  response = self._get_session().get(endpoint, params=params)
228
  result = response.json()
229
+
230
  status = result.get('status_code')
231
  logger.debug(f" Attempt {attempt}/{max_attempts}: {status}")
232
+
233
  if status == 'FINISHED':
234
  return status
235
  elif status == 'ERROR':
236
+ error_detail = result.get('status', '')
237
+ logger.error(f"❌ Instagram processing error: {error_detail}")
238
  return status
239
+
240
  time.sleep(10)
241
+
242
  return 'TIMEOUT'
243
 
244
  def _publish_container(self, container_id: str) -> Dict[str, Any]: