ZhuLinsen/daily_stock_analysis · error · IntelligenceServiceError
unsupported source_type: {source_type}
Error message
unsupported source_type: {source_type} What it means
Validation in _normalize_source_fields: source_type (default 'rss', lowercased) is not in _ALLOWED_SOURCE_TYPES = {'rss','atom','newsnow'}. Anything else is rejected before persistence.
Source
Thrown at src/services/intelligence_service.py:374
cls._auto_fetch_in_progress = False
cls._auto_fetch_condition.notify_all()
return result
def _normalize_source_fields(self, payload: Dict[str, Any]) -> Dict[str, Any]:
name = str(payload.get("name") or "").strip()
url = str(payload.get("url") or "").strip()
source_type = str(payload.get("source_type") or "rss").strip().lower()
scope_type = str(payload.get("scope_type") or "market").strip().lower()
scope_value = str(payload.get("scope_value") or "").strip() or None
market = str(payload.get("market") or "cn").strip().lower()
enabled = bool(payload.get("enabled", True))
description = str(payload.get("description") or "").strip() or None
if not name:
raise IntelligenceServiceError("source name is required")
if not url:
raise IntelligenceServiceError("source url is required")
if source_type not in _ALLOWED_SOURCE_TYPES:
raise IntelligenceServiceError(f"unsupported source_type: {source_type}")
if scope_type not in _ALLOWED_SCOPE_TYPES:
raise IntelligenceServiceError(f"unsupported scope_type: {scope_type}")
if scope_type in {"symbol", "sector"} and not scope_value:
raise IntelligenceServiceError(f"scope_value is required when scope_type={scope_type}")
if market not in _ALLOWED_MARKETS:
raise IntelligenceServiceError(f"unsupported market: {market}")
return {
"name": name[:100],
"source_type": source_type,
"url": url,
"enabled": enabled,
"scope_type": scope_type,
"scope_value": scope_value[:64] if scope_value else None,
"market": market,
"description": description,
}
def _validate_url(self, raw_url: str, *, allow_no_url: bool = False) -> None:View on GitHub (pinned to 5159bd72e8)
Solutions
- Use one of: rss, atom, newsnow (case-insensitive)
- Fetch the allowed types from API docs/schema or list_source_templates examples before building the payload
- For plain web-page sources, there is currently no supported type — use an RSS/atom feed URL instead
Example fix
# before
svc.create_source({'name':'x','url':'https://.../feed','source_type':'html'})
# after
svc.create_source({'name':'x','url':'https://.../feed.xml','source_type':'rss'}) Defensive patterns
Strategy: type-guard
Validate before calling
ALLOWED = {'rss', 'atom', 'newsnow'}
source_type = str(payload.get('source_type') or 'rss').strip().lower()
if source_type not in ALLOWED:
raise UserError(f'source_type 仅支持 {sorted(ALLOWED)}') Type guard
def is_valid_source_type(v) -> bool:
return str(v or 'rss').strip().lower() in {'rss', 'atom', 'newsnow'} Try / catch
try:
svc.create_source(payload)
except IntelligenceServiceError as e:
if 'unsupported source_type' in str(e):
payload['source_type'] = 'rss'
svc.create_source(payload)
else:
raise Prevention
- Build the type dropdown from the documented set {rss, atom, newsnow}
- Lowercase user input client-side to match backend normalization
- Keep client enums in sync with the API schema on upgrades
When it happens
Trigger: POSTing source_type like 'html', 'json', 'rss2', 'web', or 'RSS ' with stray chars that mangle after lower/strip (plain 'RSS' passes since it's lowercased).
Common situations: Assuming arbitrary feed types are supported; version drift after allowed set changed; frontend enum out of sync with backend.
Related errors
- unsupported scope_type: {scope_type}
- Desktop backend origin is invalid
- Desktop window is unavailable
- Desktop share image capture returned an empty image
- capability_unsupported
AI-assisted analysis of ZhuLinsen/daily_stock_analysis@5159bd72e8 (2026-08-15).
Data as JSON: /api/errors/efe1a22b652b9584.
Report an issue: GitHub.