{"record":{"id":"44742cf60752ba8e","repo":"ZhuLinsen/daily_stock_analysis","slug":"newsnow-api-redirects-are-not-followed","errorCode":null,"errorMessage":"NewsNow API redirects are not followed","messagePattern":"NewsNow API redirects are not followed","errorType":"exception","errorClass":"IntelligenceServiceError","httpStatus":400,"severity":"error","filePath":"src/services/intelligence_service.py","lineNumber":521,"sourceCode":"            \"User-Agent\": (\n                \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 \"\n                \"(KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 daily-stock-analysis-intel/1.0\"\n            ),\n            \"Accept\": \"application/json\",\n        }\n        self._validate_url(fields[\"url\"])\n        response = None\n        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:","sourceCodeStart":503,"sourceCodeEnd":539,"githubUrl":"https://github.com/ZhuLinsen/daily_stock_analysis/blob/5159bd72e8373d215492dff122acc9d389e219c9/src/services/intelligence_service.py#L503-L539","documentation":"Error \"NewsNow API redirects are not followed\" thrown in ZhuLinsen/daily_stock_analysis.","triggerScenarios":"Thrown at src/services/intelligence_service.py:521 when the library encounters an invalid state.","commonSituations":"Raised when the NewsNow API answers with a redirect; occurs when the NewsNow endpoint moved and redirects are intentionally not followed.","solutions":["Point the source at the final NewsNow API URL since redirects are not followed.","Update the configured URL if the provider moved the endpoint.","Remove the source if the endpoint no longer exists."],"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-15T22:17:37.221Z"}