WikipediaLoader endup in JSONDecodeError

In Module 5 research-assisant, (or in anyplace that uses wikipedialoader), my invoke stage akways end with ‘Wikipedia failed: JSONDecodeError(‘Expecting value: line 1 column 1 (char 0)’)’ , direct calling with requests api works fine, seems to be some issue with the wikipedialoader api?

Not a big issue but it’s been bugging me a lot, wondering if anyone have the same issue.

Attaching trace from langsmith

hi @Learium

the WikipediaLoader from langchain-community delegates to the unmaintained goldsmith/Wikipedia package, which calls r.json() with no fallback. As of March 2026, Wikimedia opened goldsmith/Wikipedia#350 warning that the package’s hard-coded User-Agent (wikipedia (https://github.com/goldsmith/Wikipedia/)) would be severely rate-limited starting April 2026. When rate-limited, Wikimedia returns an empty/HTML body, so r.json() raises the exact Expecting value: line 1 column 1 (char 0) error. Direct requests works because it lands in a different rate-limit bucket.

Fixes (in order):

  1. One-line patch: wikipedia.set_user_agent("research-assistant/0.1 (you@example.com)") before importing WikipediaLoader.
  2. Wrap the call to swallow JSONDecodeError.
  3. Switch to the actively-maintained wikipedia-api package (forces UA in constructor).
  4. Use raw requests against the MediaWiki Action / REST API (the user already verified this works).
  5. Authenticate via Wikimedia OAuth for production-grade limits.

Also noted that langchain-community could plausibly accept a user_agent kwarg on WikipediaAPIWrapper and translate the cryptic JSONDecodeError into something actionable - a small contribution worth filing upstream.

Thanks! Fix one indeed worked but the request takes about 3-5mintues, is it normal behavior?

Hmmm, quite long… you mean pure http request takes so long?

Soz got busy with work. Pure http request is quick, the call using the provided library with one-line patch takes super long.