ZhuLinsen/daily_stock_analysis · error · IntelligenceServiceError
invalid NewsNow JSON response: {exc}
Error message
invalid NewsNow JSON response: {exc} What it means
Error "invalid NewsNow JSON response: {exc}" thrown in ZhuLinsen/daily_stock_analysis.
Source
Thrown at src/services/intelligence_service.py:529
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:
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)
if total > _MAX_FEED_BYTES:View on GitHub (pinned to 5159bd72e8)
Solutions
- Verify the NewsNow endpoint returns valid JSON; check for HTML error pages or rate-limit responses.
- Check API credentials/keys for the NewsNow service.
- Retry later if the upstream returned a transient non-JSON error.
When it happens
Trigger: Thrown at src/services/intelligence_service.py:529 when the library encounters an invalid state.
Common situations: Raised when the NewsNow API returns a body that is not valid JSON; occurs on upstream errors, HTML error pages, or truncated responses.
AI-assisted analysis of ZhuLinsen/daily_stock_analysis@5159bd72e8 (2026-08-15).
Data as JSON: /api/errors/cbfef7f5f2aba773.
Report an issue: GitHub.