{"record":{"id":"164d0d5d43b75b1b","repo":"OpenBB-finance/OpenBB","slug":"start-date-must-be-after-2019-01-01-for-imf-port-v","errorCode":null,"errorMessage":"start_date must be after 2019-01-01 for IMF Port Volume data.","messagePattern":"start_date must be after 2019-01-01 for IMF Port Volume data\\.","errorType":"validation","errorClass":"OpenBBError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/imf/openbb_imf/models/port_volume.py","lineNumber":386,"sourceCode":"        json_schema_extra={\n            \"x-unit_measurement\": \"metric_tons\",\n            \"x-widget_config\": {\n                \"suffix\": \"mt\",\n            },\n        },\n    )\n\n\nclass ImfPortVolumeFetcher(Fetcher[ImfPortVolumeQueryParams, list[ImfPortVolumeData]]):\n    \"\"\"IMF Port Volume Fetcher.\"\"\"\n\n    @staticmethod\n    def transform_query(params: dict[str, Any]) -> ImfPortVolumeQueryParams:\n        \"\"\"Transform query parameters to the model.\"\"\"\n        if (start_date := params.get(\"start_date\")) and start_date < dateType(\n            2019, 1, 1\n        ):\n            raise OpenBBError(\n                ValueError(\n                    \"start_date must be after 2019-01-01 for IMF Port Volume data.\"\n                )\n            )\n\n        if country := params.pop(\"country\", None):\n            params[\"port_code\"] = (\n                params[\"port_code\"]\n                if params.get(\"port_code\")\n                else get_port_ids_by_country(country)\n            )\n\n        return ImfPortVolumeQueryParams(**params)\n\n    @staticmethod\n    async def aextract_data(\n        query: ImfPortVolumeQueryParams,\n        credentials: dict[str, str] | None,","sourceCodeStart":368,"sourceCodeEnd":404,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/imf/openbb_imf/models/port_volume.py#L368-L404","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\nres = await obb.economy.port_volume(provider='imf', start_date='2010-01-01')\n\n# after\nres = await obb.economy.port_volume(provider='imf', start_date='2019-01-01')","handlingStrategy":"validation","validationCode":"from datetime import date\nparams = {'provider': 'imf'}\nif start_date:\n    params['start_date'] = max(start_date, date(2019, 1, 1))\nres = await obb.economy.port_volume(**params)","typeGuard":null,"tryCatchPattern":"try:\n    result = ImfPortVolumeFetcher.transform_query(params)\nexcept OpenBBError as e:\n    if 'must be after 2019-01-01' in str(e):\n        params['start_date'] = date(2019, 1, 1)\n        result = ImfPortVolumeFetcher.transform_query(params)","preventionTips":["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."],"tags":["validation","date-bounds","imf","fetcher","ports"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}