ZhuLinsen/daily_stock_analysis · error · IntelligenceServiceError

feed redirect missing Location header

Error message

feed redirect missing Location header

What it means

Error "feed redirect missing Location header" thrown in ZhuLinsen/daily_stock_analysis.

Source

Thrown at src/services/intelligence_service.py:464

        timeout = max(1, min(float(self.config.news_intel_fetch_timeout_sec), 30.0))
        headers = {"User-Agent": "daily-stock-analysis-intel/1.0"}
        self._validate_url(fields["url"])
        request_url = fields["url"]
        response = None
        try:
            for _ in range(_MAX_FEED_REDIRECTS + 1):
                response = self._get_with_validated_dns(
                    request_url,
                    timeout=timeout,
                    headers=headers,
                    allow_redirects=False,
                    stream=True,
                )
                status_code = int(getattr(response, "status_code", 200))
                if status_code in _REDIRECT_STATUS_CODES:
                    location = getattr(response, "headers", {}).get("Location")
                    if not location:
                        raise IntelligenceServiceError("feed redirect missing Location header")
                    response.close()
                    request_url = urljoin(request_url, location)
                    self._validate_url(request_url)
                    continue
                response.raise_for_status()
                break
            else:
                raise IntelligenceServiceError(f"feed redirect chain exceeds {_MAX_FEED_REDIRECTS}")

            self._validate_url(response.url or request_url)

            if hasattr(response, "iter_content") and callable(response.iter_content):
                chunks = []
                total = 0
                for chunk in response.iter_content(chunk_size=8192):
                    if not chunk:
                        continue
                    total += len(chunk)

View on GitHub (pinned to 5159bd72e8)

Solutions

  1. The feed redirect response lacked a Location header; verify the feed URL directly.
  2. Update the source to the final feed URL to avoid the broken redirect.
  3. Contact the feed provider or replace the source if the redirect is permanently broken.

When it happens

Trigger: Thrown at src/services/intelligence_service.py:464 when the library encounters an invalid state.

Common situations: Raised when a feed redirect response lacks a Location header; occurs with misbehaving upstream servers returning 3xx without a target.


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