fix(reddit): re-raise HTTP 402 so fallback chain triggers
The ScrapeCreators 402 (payment required / credits exhausted) status was being swallowed by the broad except Exception handlers in _global_search, _subreddit_search, and fetch_post_comments, returning [] instead of propagating. That caused users with exhausted credits to silently get zero Reddit results instead of falling through to the OpenAI / public Reddit JSON fallback chain in _search_reddit_thread. Add 402 to the existing 401/403 re-raise list across all three ScrapeCreators call paths. Closes #170. Co-authored-by: Jonathan Oppenheim <no-reply@postquantum.space>
This commit is contained in:
@@ -334,7 +334,7 @@ def _global_search(
|
|||||||
)
|
)
|
||||||
return data.get("posts", data.get("data", []))
|
return data.get("posts", data.get("data", []))
|
||||||
except http.HTTPError as e:
|
except http.HTTPError as e:
|
||||||
if e.status_code in (401, 403):
|
if e.status_code in (401, 402, 403):
|
||||||
raise
|
raise
|
||||||
_log(f"Global search error: {e}")
|
_log(f"Global search error: {e}")
|
||||||
return []
|
return []
|
||||||
@@ -376,6 +376,11 @@ def _subreddit_search(
|
|||||||
retries=2,
|
retries=2,
|
||||||
)
|
)
|
||||||
return data.get("posts", data.get("data", []))
|
return data.get("posts", data.get("data", []))
|
||||||
|
except http.HTTPError as e:
|
||||||
|
if e.status_code in (401, 402, 403):
|
||||||
|
raise
|
||||||
|
_log(f"Subreddit search error for r/{subreddit}: {e}")
|
||||||
|
return []
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
_log(f"Subreddit search error for r/{subreddit}: {e}")
|
_log(f"Subreddit search error for r/{subreddit}: {e}")
|
||||||
return []
|
return []
|
||||||
@@ -403,6 +408,11 @@ def fetch_post_comments(
|
|||||||
retries=2,
|
retries=2,
|
||||||
)
|
)
|
||||||
return data.get("comments", data.get("data", []))
|
return data.get("comments", data.get("data", []))
|
||||||
|
except http.HTTPError as e:
|
||||||
|
if e.status_code in (401, 402, 403):
|
||||||
|
raise
|
||||||
|
_log(f"Comment fetch error: {e}")
|
||||||
|
return []
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
_log(f"Comment fetch error: {e}")
|
_log(f"Comment fetch error: {e}")
|
||||||
return []
|
return []
|
||||||
|
|||||||
Reference in New Issue
Block a user