OpenBB-finance/OpenBB · error · OpenBBError
start_date must be after 2019-01-01 for IMF Port Volume data
Error message
start_date must be after 2019-01-01 for IMF Port Volume data.
What it means
Identical date-floor check to the query-param validator, but implemented in ImfPortVolumeFetcher.transform_query before the params dict is turned into the query model. It exists so that callers invoking the fetcher directly (or through the router with raw dicts) get a clear dataset-specific message. If params already carry a start_date below 2019-01-01, this raises before any network call.
Source
Thrown at openbb_platform/providers/imf/openbb_imf/models/port_volume.py:386
json_schema_extra={
"x-unit_measurement": "metric_tons",
"x-widget_config": {
"suffix": "mt",
},
},
)
class ImfPortVolumeFetcher(Fetcher[ImfPortVolumeQueryParams, list[ImfPortVolumeData]]):
"""IMF Port Volume Fetcher."""
@staticmethod
def transform_query(params: dict[str, Any]) -> ImfPortVolumeQueryParams:
"""Transform query parameters to the model."""
if (start_date := params.get("start_date")) and start_date < dateType(
2019, 1, 1
):
raise OpenBBError(
ValueError(
"start_date must be after 2019-01-01 for IMF Port Volume data."
)
)
if country := params.pop("country", None):
params["port_code"] = (
params["port_code"]
if params.get("port_code")
else get_port_ids_by_country(country)
)
return ImfPortVolumeQueryParams(**params)
@staticmethod
async def aextract_data(
query: ImfPortVolumeQueryParams,
credentials: dict[str, str] | None,View on GitHub (pinned to 3e071fcc2c)
Solutions
- Pass start_date >= 2019-01-01 (or leave it None) to the fetcher/router call.
- Clamp the date before invoking: start_date = max(start_date, date(2019,1,1)) when start_date is not None.
- Prefer going through the standard router so the query-param validator gives the clearer message first.
Example fix
# before res = await obb.economy.port_volume(provider='imf', start_date='2010-01-01') # after res = await obb.economy.port_volume(provider='imf', start_date='2019-01-01')
Defensive patterns
Strategy: validation
Validate before calling
from datetime import date
params = {'provider': 'imf'}
if start_date:
params['start_date'] = max(start_date, date(2019, 1, 1))
res = await obb.economy.port_volume(**params) Try / catch
try:
result = ImfPortVolumeFetcher.transform_query(params)
except OpenBBError as e:
if 'must be after 2019-01-01' in str(e):
params['start_date'] = date(2019, 1, 1)
result = ImfPortVolumeFetcher.transform_query(params) Prevention
- Apply the 2019-01-01 floor at the edge of your application, once, for all IMF port calls.
- Prefer the router over direct fetcher calls so both guards see sanitized params.
When it happens
Trigger: ImfPortVolumeFetcher.transform_query({'start_date': date(2017,1,1), ...}) called directly; router calls where the params dict bypasses or has not yet run the Pydantic validator.
Common situations: Custom integrations that call the fetcher or provider machinery directly instead of the obb router; tests feeding raw parameter dicts; version upgrades where the check moved between model and fetcher.
Related errors
- Minimum start_date is 2019-01-01. Got {values['start_date']}
- Expected values as valid portIDs, got None instead.
- No valid port_code provided.
- Failed to fetch data for port {port_code}: {e} -> {e.args}
- No data found for the specified port(s). {port_codes} Ensure
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/164d0d5d43b75b1b.
Report an issue: GitHub.