ZhuLinsen/daily_stock_analysis · warning · IntelligenceServiceError

Intelligence source is disabled: {source_id}

Error message

Intelligence source is disabled: {source_id}

What it means

fetch_source refuses to fetch a source whose enabled flag is false. The row exists but is disabled, so the service blocks the network fetch instead of silently pulling from an opted-out feed.

Source

Thrown at src/services/intelligence_service.py:257

            "page_size": max(1, min(int(filters.get("page_size") or 50), 100)),
        }

    def test_source(self, payload: Dict[str, Any]) -> Dict[str, Any]:
        fields = self._normalize_source_fields(payload)
        entries = self._fetch_feed_entries(fields, limit=min(5, self.config.news_intel_max_items_per_source))
        return {
            "ok": True,
            "source": self._redact_source_fields(fields),
            "fetched_count": len(entries),
            "sample_items": [self._feed_entry_to_dict(entry) for entry in entries[:5]],
        }

    def fetch_source(self, source_id: int, *, dry_run: bool = False) -> Dict[str, Any]:
        source = self.repo.get_source(source_id)
        if source is None:
            raise IntelligenceServiceError(f"Intelligence source not found: {source_id}")
        if not source.enabled:
            raise IntelligenceServiceError(f"Intelligence source is disabled: {source_id}")
        now = datetime.now()
        try:
            entries = self._fetch_feed_entries(self._source_to_fields(source), limit=self.config.news_intel_max_items_per_source)
            item_fields = [self._entry_to_item_fields(entry, source, now) for entry in entries]
            saved = 0 if dry_run else self.repo.upsert_items(item_fields)
            deleted = 0 if dry_run else self.repo.apply_retention(self.config.news_intel_retention_days)
            if not dry_run:
                self.repo.update_source_status(source.id, status="success", error=None, fetched_at=now)
            return {
                "ok": True,
                "source_id": source.id,
                "fetched_count": len(entries),
                "saved_count": saved,
                "retention_deleted": deleted,
                "dry_run": dry_run,
                "sample_items": [self._feed_entry_to_dict(entry) for entry in entries[:5]],
            }
        except Exception as exc:

View on GitHub (pinned to 5159bd72e8)

Solutions

  1. Enable the source first: update_source(source_id, {'enabled': True}) or the UI toggle, then fetch
  2. If it should stay disabled, remove it from fetch schedules/automation
  3. Check the 'enabled' field in list_sources output before triggering fetch

Example fix

# before
svc.fetch_source(sid)  # disabled -> error
# after
svc.update_source(sid, {'enabled': True})
svc.fetch_source(sid)
Defensive patterns

Strategy: validation

Validate before calling

src = svc.repo.get_source(source_id)
if src and not src.enabled:
    svc.update_source(source_id, {'enabled': True})
service.fetch_source(source_id)

Type guard

def is_fetchable(src) -> bool:
    return src is not None and bool(src.enabled)

Try / catch

try:
    svc.fetch_source(sid)
except IntelligenceServiceError as e:
    if 'disabled' in str(e):
        svc.update_source(sid, {'enabled': True})
        svc.fetch_source(sid)
    else:
        raise

Prevention

When it happens

Trigger: Calling fetch on a source created with enabled=False (create_default_sources defaults new sources to disabled) that was never toggled on.

Common situations: Bulk-creating default templates (they start disabled) then immediately trying to fetch; disabling a noisy source but a scheduled job still referencing it.

Related errors


AI-assisted analysis of ZhuLinsen/daily_stock_analysis@5159bd72e8 (2026-08-15). Data as JSON: /api/errors/12050eaef3bcf0d1. Report an issue: GitHub.