Răsfoiți Sursa

Fix NoneType crash when Airbnb GQL returns data: null

resp.get('data', {}) only falls back to {} when the key is missing,
not when the value is None, so a non-auth-shaped GQL error (data: null)
crashed the next .get() call in the chain instead of degrading gracefully.
ZiB 5 zile în urmă
părinte
comite
581e12aa0d
1 a modificat fișierele cu 5 adăugiri și 5 ștergeri
  1. 5 5
      room_cal/service_api/_airbnb.py

+ 5 - 5
room_cal/service_api/_airbnb.py

@@ -261,7 +261,7 @@ class _AirbnbClient(ServiceClientBase):
     referer = f'https://www.airbnb.com/multicalendar/{self._listing_id}'
     resp = await self._gql('getDLSHostCalendar', _HASHES['getDLSHostCalendar'], variables, referer)
     section = (
-      resp.get('data', {}).get('presentation', {})
+      (resp.get('data') or {}).get('presentation', {})
           .get('hostCalendar', {}).get('sections', {})
           .get('calendarGridViewSection')
     ) or {}
@@ -468,7 +468,7 @@ class _AirbnbClient(ServiceClientBase):
       _log.warning('airbnb: StayHostingDetailsQuery timed out for %s — skipping', code)
       return {}
     det = (
-      resp.get('data', {}).get('presentation', {})
+      (resp.get('data') or {}).get('presentation', {})
           .get('hostingDetails', {}).get('stayHostingDetails', {})
     )
     self._details.set(code, det)
@@ -531,7 +531,7 @@ class _AirbnbClient(ServiceClientBase):
       },
       f'https://www.airbnb.com/messages/{thread_id}',
     )
-    thread_data = resp.get('data', {}).get('threadData', {})
+    thread_data = (resp.get('data') or {}).get('threadData', {})
     participants: dict[str, str] = {}
     for edge in thread_data.get('participants', {}).get('edges', []):
       node = edge.get('node', {})
@@ -586,7 +586,7 @@ class _AirbnbClient(ServiceClientBase):
       f'https://www.airbnb.com/multicalendar/{self._listing_id}',
     )
     tips = (
-      resp.get('data', {}).get('presentation', {})
+      (resp.get('data') or {}).get('presentation', {})
           .get('pricingGuidance', {}).get('nightlyPriceTip', {})
           .get('nightlyPriceTip', {}).get('discretePriceTips', [])
     )
@@ -612,7 +612,7 @@ class _AirbnbClient(ServiceClientBase):
       f'https://www.airbnb.com/multicalendar/{self._listing_id}',
     )
     events = (
-      resp.get('data', {}).get('presentation', {})
+      (resp.get('data') or {}).get('presentation', {})
           .get('hostCalendarListingEvents', {}).get('events', [])
     )
     return [