{"record":{"id":"cbfef7f5f2aba773","repo":"ZhuLinsen/daily_stock_analysis","slug":"invalid-newsnow-json-response-exc","errorCode":null,"errorMessage":"invalid NewsNow JSON response: {exc}","messagePattern":"invalid NewsNow JSON response: (.+?)","errorType":"exception","errorClass":"IntelligenceServiceError","httpStatus":400,"severity":"error","filePath":"src/services/intelligence_service.py","lineNumber":529,"sourceCode":"        try:\n            response = self._get_with_validated_dns(\n                fields[\"url\"],\n                timeout=timeout,\n                headers=headers,\n                allow_redirects=False,\n                stream=True,\n            )\n            status_code = int(getattr(response, \"status_code\", 200))\n            if status_code in _REDIRECT_STATUS_CODES:\n                raise IntelligenceServiceError(\"NewsNow API redirects are not followed\")\n            response.raise_for_status()\n            self._validate_url(response.url or fields[\"url\"])\n\n            content = self._read_limited_response(response)\n            try:\n                payload = json.loads(content.decode(\"utf-8\"))\n            except (UnicodeDecodeError, json.JSONDecodeError) as exc:\n                raise IntelligenceServiceError(f\"invalid NewsNow JSON response: {exc}\") from exc\n            return self._parse_newsnow_payload(payload, source_name=fields[\"name\"], limit=limit)\n        except IntelligenceServiceError:\n            raise\n        except Exception as exc:\n            raise IntelligenceServiceError(_UPSTREAM_FETCH_FAILURE_MESSAGE) from exc\n        finally:\n            if response is not None:\n                response.close()\n\n    def _read_limited_response(self, response: requests.Response) -> bytes:\n        if hasattr(response, \"iter_content\") and callable(response.iter_content):\n            chunks = []\n            total = 0\n            for chunk in response.iter_content(chunk_size=8192):\n                if not chunk:\n                    continue\n                total += len(chunk)\n                if total > _MAX_FEED_BYTES:","sourceCodeStart":511,"sourceCodeEnd":547,"githubUrl":"https://github.com/ZhuLinsen/daily_stock_analysis/blob/5159bd72e8373d215492dff122acc9d389e219c9/src/services/intelligence_service.py#L511-L547","documentation":"Error \"invalid NewsNow JSON response: {exc}\" thrown in ZhuLinsen/daily_stock_analysis.","triggerScenarios":"Thrown at src/services/intelligence_service.py:529 when the library encounters an invalid state.","commonSituations":"Raised when the NewsNow API returns a body that is not valid JSON; occurs on upstream errors, HTML error pages, or truncated responses.","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."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5159bd72e8373d215492dff122acc9d389e219c9","analyzedAt":"2026-08-15T01:59:36.292Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}