{"record":{"id":"d80978f9875bad3b","repo":"OpenBB-finance/OpenBB","slug":"e-d80978","errorCode":null,"errorMessage":"{e}","messagePattern":"\\{e\\}","errorType":"exception","errorClass":"OpenBBError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/imf/openbb_imf/models/port_info.py","lineNumber":275,"sourceCode":"\n                            async with await session.get(url) as response:\n                                if response.status != 200:\n                                    raise OpenBBError(\n                                        f\"Failed to fetch data: {response.status}\"\n                                    )\n\n                                data = await response.json()\n                                if \"features\" in data:\n                                    output.extend(data[\"features\"])\n\n            return sorted(\n                output,\n                key=lambda x: x[\"attributes\"][\"vessel_count_total\"],\n                reverse=True,\n            )\n\n        except Exception as e:\n            raise OpenBBError(e) from e\n\n    @staticmethod\n    def transform_data(\n        query: ImfPortInfoQueryParams,\n        data: list,\n        **kwargs: Any,\n    ) -> list[ImfPortInfoData]:\n        \"\"\"Transform the raw data into a list of ImfPortInfoData.\"\"\"\n        results: list[ImfPortInfoData] = []\n\n        if query.country:\n            results.extend(\n                [\n                    ImfPortInfoData(**d[\"attributes\"])\n                    for d in sorted(\n                        data,\n                        key=lambda x: x[\"attributes\"][\"vessel_count_total\"],\n                        reverse=True,","sourceCodeStart":257,"sourceCodeEnd":293,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/imf/openbb_imf/models/port_info.py#L257-L293","documentation":"Outer catch-all in the port_info fetcher: any exception escaping the fetch body (non-200 handled above, plus JSON decode errors, KeyErrors on unexpected payload shape like sorting when 'attributes'/'vessel_count_total' is missing, TLS/DNS failures) is re-raised as OpenBBError with the original preserved as `__cause__`. The message is the inner exception's str.","triggerScenarios":"Sorting the features raises KeyError when a record lacks `attributes.vessel_count_total`; `response.json()` fails on truncated HTML error pages; DNS/TLS errors to services9.arcgis.com.","commonSituations":"PortWatch schema changes removing/renaming vessel_count_total; captive portals or proxies returning HTML; intermittent network conditions.","solutions":["Inspect `e.__cause__` — a KeyError points to a schema change (update the provider), a ClientError points to network.","Retry on network-type causes.","Upgrade openbb_imf if the underlying ArcGIS schema changed.","Verify egress/proxy settings for services9.arcgis.com."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"except OpenBBError as e:\n    cause = e.__cause__\n    if isinstance(cause, KeyError):\n        log.error('PortWatch schema changed: %s', cause)  # update provider\n    elif isinstance(cause, (TimeoutError, ConnectionError)):\n        await asyncio.sleep(5)\n        ports = await obb.economy.imf.port_info()\n    else:\n        raise","preventionTips":["Branch on e.__cause__ type: KeyError means schema drift (upgrade provider), network errors mean retry","Keep the provider updated when PortWatch evolves its attributes"],"tags":["imf","portwatch","wrapper-exception","network"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}