ZhuLinsen/daily_stock_analysis · error · IntelligenceServiceError

NewsNow API redirects are not followed

Error message

NewsNow API redirects are not followed

What it means

Error "NewsNow API redirects are not followed" thrown in ZhuLinsen/daily_stock_analysis.

Source

Thrown at src/services/intelligence_service.py:521

            "User-Agent": (
                "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
                "(KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 daily-stock-analysis-intel/1.0"
            ),
            "Accept": "application/json",
        }
        self._validate_url(fields["url"])
        response = None
        try:
            response = self._get_with_validated_dns(
                fields["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:
                raise IntelligenceServiceError("NewsNow API redirects are not followed")
            response.raise_for_status()
            self._validate_url(response.url or fields["url"])

            content = self._read_limited_response(response)
            try:
                payload = json.loads(content.decode("utf-8"))
            except (UnicodeDecodeError, json.JSONDecodeError) as exc:
                raise IntelligenceServiceError(f"invalid NewsNow JSON response: {exc}") from exc
            return self._parse_newsnow_payload(payload, source_name=fields["name"], limit=limit)
        except IntelligenceServiceError:
            raise
        except Exception as exc:
            raise IntelligenceServiceError(_UPSTREAM_FETCH_FAILURE_MESSAGE) from exc
        finally:
            if response is not None:
                response.close()

    def _read_limited_response(self, response: requests.Response) -> bytes:

View on GitHub (pinned to 5159bd72e8)

Solutions

  1. Point the source at the final NewsNow API URL since redirects are not followed.
  2. Update the configured URL if the provider moved the endpoint.
  3. Remove the source if the endpoint no longer exists.

When it happens

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

Common situations: Raised when the NewsNow API answers with a redirect; occurs when the NewsNow endpoint moved and redirects are intentionally not followed.


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