datawhalechina/hello-agents · error · ExternalAPIException
IEEE API请求失败: {response.status}
Error message
IEEE API请求失败: {response.status} What it means
ExternalAPIException from HunterAgent._search_papers_from_ieee when the GET to ieee_base_url returns non-200. Unlike arXiv, IEEE Xplore requires an API key sent as 'apikey'; the code falls back to "" when config.ieee_api_key is unset, so 401/403 (missing/invalid key) and 400 (bad querytext) are the dominant causes, alongside 429 quota exhaustion.
Source
Thrown at Co-creation-projects/Apricity-InnocoreAI/agents/hunter.py:174
return papers
# 构建查询参数
query = " OR ".join([f'"All Meta Data:{keyword}"' for keyword in keywords])
params = {
"apikey": config.ieee_api_key or "",
"querytext": query,
"max_records": max_papers * 2,
"start_record": 1,
"sort_order": "desc",
"sort_field": "publication_date"
}
try:
async with aiohttp.ClientSession() as session:
async with session.get(self.ieee_base_url, params=params) as response:
if response.status != 200:
raise ExternalAPIException(f"IEEE API请求失败: {response.status}")
data = await response.json()
for article in data.get("articles", []):
paper = {
"id": article.get("article_number", ""),
"title": article.get("title", ""),
"authors": [author.get("full_name", "") for author in article.get("authors", {}).get("authors", [])],
"abstract": article.get("abstract", ""),
"published": article.get("publication_date", ""),
"pdf_url": article.get("pdf_url", ""),
"source": "ieee",
"doi": article.get("doi", ""),
"categories": article.get("index_terms", {}).get("ieee_terms", {}).get("terms", [])
}
papers.append(paper)
View on GitHub (pinned to 606a07d341)
Solutions
- Set a valid IEEE_XPLORE API key (request at developer.ieee.org) in config/.env and restart.
- On 401/403: verify the key is loaded (config.ieee_api_key truthy) before calling, and skip IEEE when it is empty.
- On 429: check quota usage on the IEEE developer portal, cache results, and reduce max_records per request.
- On 400: simplify querytext to plain quoted keywords and URL-encode via params.
- Confirm ieee_base_url matches the current documented endpoint version.
Example fix
# before
async def _search_papers_from_iee(...):
params = {"apikey": config.ieee_api_key or "", ...}
... raise ExternalAPIException(f"IEEE API请求失败: {response.status}")
# after — fail fast on missing key, make source optional
async def _search_papers_from_iee(self, ...):
if not config.ieee_api_key:
logger.warning("IEEE API key 未配置,跳过 IEEE 搜索")
return []
params = {"apikey": config.ieee_api_key, ...}
if response.status == 401:
raise ExternalAPIException("IEEE API key 无效或未配置")
if response.status != 200:
raise ExternalAPIException(f"IEEE API请求失败: {response.status}") Defensive patterns
Strategy: validation
Validate before calling
# Never call IEEE without a key — validate config first
if "ieee" in sources:
if not (config.ieee_api_key or "").strip():
logger.warning("IEEE_API_KEY missing; dropping 'ieee' from sources")
sources = [s for s in sources if s != "ieee"] Try / catch
try:
papers = await hunter._search_papers_from_iee(...)
except ExternalAPIException as e:
if "401" in str(e) or "403" in str(e):
logger.error("IEEE key invalid/missing — skipping IEEE")
papers = [] # degrade gracefully, arXiv results still flow
else:
raise Prevention
- Request and configure an IEEE Xplore key before enabling the ieee source.
- Treat IEEE as an optional source: one failed source should not kill the whole hunt.
- Monitor quota (429) and cache responses to conserve the weekly limit.
When it happens
Trigger: IEEE_API_KEY absent from environment so params['apikey']='' -> 401; expired or over-quota key -> 401/429; querytext with unencoded operators exceeding the API's grammar -> 400; wrong ieee_base_url after an endpoint version change.
Common situations: Fresh clone without .env configured; key rotated but process still holds the old value; free-tier weekly quota exhausted mid-run; developer environment where IEEE is enabled by default though no key was ever requested.
Related errors
- ArXiv API请求失败: {response.status}
- LLM思考失败: {str(e)}
- API 请求频率已达上限(429 Too Many Requests)。\nSemantic Scholar 免费额度为
- 工具 '{tool_name}' 执行超时
- Hunter Agent执行失败: {str(e)}
AI-assisted analysis of datawhalechina/hello-agents@606a07d341 (2026-08-14).
Data as JSON: /api/errors/bb7463507566939b.
Report an issue: GitHub.