{"record":{"id":"e4294f51534281db","repo":"OpenBB-finance/OpenBB","slug":"failed-to-retrieve-data-unexpected-response-from","errorCode":null,"errorMessage":"Failed to retrieve data. Unexpected response from the server. Status code: {response.status_code} -> Response content: {response_content}","messagePattern":"Failed to retrieve data\\. Unexpected response from the server\\. Status code: (.+?) -> Response content: (.+?)","errorType":"http","errorClass":"OpenBBError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/government_us/openbb_government_us/models/commodity_psd_report.py","lineNumber":163,"sourceCode":"        api_commodity = COMMODITIES.get(query.commodity.lower(), query.commodity)\n        month = f\"{query.month:02d}\"\n        url = f\"https://apps.fas.usda.gov/PSDOnline/CircularDownloader.ashx?year={query.year}&month={month}&commodity={api_commodity}\"\n        output = b\"\"\n\n        try:\n            response = make_request(url)\n\n            if response.status_code == 404 or not response.content:\n                raise OpenBBError(\n                    ValueError(\n                        \"No data found for the given parameters. Please check the commodity, year, and month.\"\n                    )\n                )\n\n            if response.status_code == 200 and response.content[:4] == b\"%PDF\":\n                output = response.content\n            else:\n                raise OpenBBError(\n                    ValueError(\n                        \"Failed to retrieve data. Unexpected response from the server.\"\n                        + f\" Status code: {response.status_code} -> \"\n                        + f\"Response content: {response.content.decode('utf-8', errors='ignore')}\"\n                    )\n                )\n        except Exception as e:\n            raise OpenBBError(e) from e\n\n        return {\"content\": output}\n\n    @staticmethod\n    def transform_data(\n        query: GovernmentUsCommodityPsdReportQueryParams,\n        data: dict,\n        **kwargs: Any,\n    ) -> GovernmentUsCommodityPsdReportData:\n        \"\"\"Transform data into the encoded format.\"\"\"","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/government_us/openbb_government_us/models/commodity_psd_report.py#L145-L181","documentation":"Error \"Failed to retrieve data. Unexpected response from the server. Status code: {response.status_code} -> Response content: {response_content}\" thrown in OpenBB-finance/OpenBB.","triggerScenarios":"Thrown at openbb_platform/providers/government_us/openbb_government_us/models/commodity_psd_report.py:163 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the request; the server returned an unexpected response.","Check the status code and response content in the message for details.","Try again later if the USDA server is having issues."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}