OpenBB-finance/OpenBB · error · OpenBBError
Error fetching ports data: {e} -> {e.args}
Error message
Error fetching ports data: {e} -> {e.args} What it means
Catch-all wrapper in get_ports: any exception raised inside the async fetch (including the non-200 OpenBBError from 621, JSON decode errors, or client disconnects) is re-raised as an OpenBBError with the original exception and its args. It signals the ports lookup failed for an underlying reason detailed in the message.
Source
Thrown at openbb_platform/providers/imf/openbb_imf/utils/port_watch_helpers.py:429
ports: list[dict] = []
try:
async with await get_async_requests_session() as session, await session.get(
url
) as response:
if response.status != 200:
raise OpenBBError(
f"Failed to fetch ports data: {response.status} - {response.reason}"
)
data = await response.json()
for feature in data.get("features", []):
ports.append(feature.get("attributes", {}))
return ports
except Exception as e:
raise OpenBBError(f"Error fetching ports data: {e} -> {e.args}") from e
def get_ports() -> list[dict[str, Any]]:
"""Get the list of all ports synchronously."""
# pylint: disable=import-outside-toplevel
import asyncio
try:
loop = asyncio.get_running_loop()
except RuntimeError:
loop = None
if loop is not None:
# Already in an async context
import concurrent.futures
with concurrent.futures.ThreadPoolExecutor() as executor:
future = executor.submit(asyncio.run, list_ports())View on GitHub (pinned to 3e071fcc2c)
Solutions
- Read the inner exception text after '->': it names the true cause (e.g. TimeoutError, ContentTypeError, status code).
- Fix the underlying cause: network connectivity, proxy/TLS config, or simply retry for transient faults.
- Verify the ports FeatureServer URL responds with JSON (curl with ?f=json).
- If the inner error is the status-code OpenBBError, follow the guidance for that error (retry/backoff).
Defensive patterns
Strategy: try-catch
Try / catch
try:
ports = await get_ports()
except OpenBBError as e:
msg = str(e)
if 'ClientConnectorError' in msg or 'Timeout' in msg:
handle_network_issue(msg)
elif 'Failed to fetch ports data' in msg:
handle_http_status(msg)
else:
raise Prevention
- Always read the embedded inner exception after '->' before retrying; the wrapper hides the class.
- Use a local cache of the ports table so a single upstream hiccup does not break every PortWatch call.
- Verify proxy/TLS config once in CI against services9.arcgis.com.
When it happens
Trigger: The session.get throws (DNS failure, TLS error, timeout), response.json() fails on a non-JSON error page, or the status-check OpenBBError at line 421 propagates into this handler.
Common situations: Offline environments, SSL certificate issues behind corporate proxies, ArcGIS returning an HTML error page instead of JSON, or any transient network fault during the ports-table bootstrap.
Related errors
- Failed to fetch data: {response.status}
- {e}
- {task_result}
- Failed to fetch data: {response.status} -> {response.reason}
- Failed to fetch data: {response.status}
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/a931b03eefd6bbd5.
Report an issue: GitHub.