Description
get_subreddit_info raises a KeyError: 'active_user_count' for any subreddit. Reddit's API has removed the active_user_count field from subreddit responses, causing the underlying redditwarp library to crash during model construction.
Steps to Reproduce
Call the get_subreddit_info tool with any subreddit name:
{"name": "get_subreddit_info", "arguments": {"subreddit_name": "python"}}
Error
KeyError: 'active_user_count'
Root Cause
The crash originates in redditwarp (dependency), specifically in redditwarp/models/subreddit.py:
self.viewing_count: int = -1 if (x := d['active_user_count']) is None else x
This uses bracket access (d['active_user_count']) instead of .get(), so when Reddit's API no longer includes the field, it raises KeyError.
The call chain is:
mcp-server-reddit calls self.client.p.subreddit.fetch_by_name(subreddit_name) in server.py
redditwarp constructs a Subreddit model from the API response
- The model constructor does
d['active_user_count'] on the raw JSON — crashes
Suggested Fix
Option A (upstream): File on Pyprohly/redditwarp to change d['active_user_count'] to d.get('active_user_count').
Option B (in this repo): Wrap the get_subreddit_info call in a try/except and return a degraded response (omitting active_user_count) when the field is missing.
Environment
- mcp-server-reddit: v1.26.0
- redditwarp: (latest via pip)
- Transport: supergateway (Streamable HTTP)
Description
get_subreddit_inforaises aKeyError: 'active_user_count'for any subreddit. Reddit's API has removed theactive_user_countfield from subreddit responses, causing the underlyingredditwarplibrary to crash during model construction.Steps to Reproduce
Call the
get_subreddit_infotool with any subreddit name:{"name": "get_subreddit_info", "arguments": {"subreddit_name": "python"}}Error
Root Cause
The crash originates in
redditwarp(dependency), specifically inredditwarp/models/subreddit.py:This uses bracket access (
d['active_user_count']) instead of.get(), so when Reddit's API no longer includes the field, it raisesKeyError.The call chain is:
mcp-server-redditcallsself.client.p.subreddit.fetch_by_name(subreddit_name)inserver.pyredditwarpconstructs aSubredditmodel from the API responsed['active_user_count']on the raw JSON — crashesSuggested Fix
Option A (upstream): File on
Pyprohly/redditwarpto changed['active_user_count']tod.get('active_user_count').Option B (in this repo): Wrap the
get_subreddit_infocall in a try/except and return a degraded response (omittingactive_user_count) when the field is missing.Environment