{"record":{"id":"8526ee9c9dcaf866","repo":"OpenBB-finance/OpenBB","slug":"requested-end-date-end-date-is-before-the-earl","errorCode":null,"errorMessage":"Requested end_date '{end_date}' is before the earliest available data '{time_start}'. Available date range: {time_start} to {time_end}","messagePattern":"Requested end_date '(.+?)' is before the earliest available data '(.+?)'\\. Available date range: (.+?) to (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"openbb_platform/providers/imf/openbb_imf/utils/query_builder.py","lineNumber":294,"sourceCode":"                            for annotation in constraint.get(\"annotations\", []):\n                                ann_id = annotation.get(\"id\", \"\")\n                                ann_title = annotation.get(\"title\", \"\")\n                                if ann_id == \"time_period_start\":\n                                    time_start = ann_title\n                                elif ann_id == \"time_period_end\":\n                                    time_end = ann_title\n\n                    if time_start and time_end:\n                        # Use >= because time_end represents the END of the last period\n                        # e.g., time_end=2025-01-01 means data up to end of 2024\n                        # So start_date=2025-01-01 would be requesting data AFTER the available range\n                        if start_date and start_date >= time_end:\n                            raise ValueError(\n                                f\"Requested start_date '{start_date}' is after the latest available data '{time_end}'. \"\n                                f\"Available date range: {time_start} to {time_end}\"\n                            )\n                        if end_date and end_date <= time_start:\n                            raise ValueError(\n                                f\"Requested end_date '{end_date}' is before the earliest available data '{time_start}'. \"\n                                f\"Available date range: {time_start} to {time_end}\"\n                            )\n\n        except KeyError as e:\n            # Dataflow not found or other metadata issue - let it pass through\n            warnings.warn(\n                f\"Could not validate constraints for dataflow '{dataflow}': {e}\",\n                OpenBBWarning,\n            )\n\n    def fetch_data(\n        self,\n        dataflow: str,\n        start_date: str | None = None,\n        end_date: str | None = None,\n        limit: int | None = None,\n        _skip_validation: bool = False,","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/imf/openbb_imf/utils/query_builder.py#L276-L312","documentation":"Companion to 630: build_url raises ValueError when end_date <= time_start, i.e. the entire requested window precedes the earliest observation the dataflow publishes. The message includes the actual available range.","triggerScenarios":"Requesting end_date='1990-12-31' for a dataflow whose data starts in 2000; backfill jobs targeting periods before the series existed.","commonSituations":"Uniform corporate history windows (e.g. 1970+) applied to every dataset, or new dataflows with short histories.","solutions":["Move end_date after the time_start in the message, or drop end_date entirely.","Confirm the series' start date on the IMF catalog.","Skip the call for dataflows whose history does not intersect your required window."],"exampleFix":"# before\nurl = qb.build_url('DATAFLOW', end_date='1990-12-31')  # data starts 2000\n\n# after\nurl = qb.build_url('DATAFLOW', end_date='2025-12-31')","handlingStrategy":"validation","validationCode":"def clamp_end_date(qb, dataflow: str, end_date: str) -> str:\n    rng = get_time_period_range(qb, dataflow)\n    if rng and end_date <= rng[0]:\n        return rng[1]\n    return end_date","typeGuard":null,"tryCatchPattern":"try:\n    url = qb.build_url(dataflow, end_date=end_date)\nexcept ValueError as e:\n    m = re.search(r'range: (.+) to (.+)', str(e))\n    if m and 'before the earliest' in str(e):\n        url = qb.build_url(dataflow, end_date=m.group(2))\n    else:\n        raise","preventionTips":["Skip dataflows whose time range does not intersect your required window.","Check series start dates on the IMF catalog before running historical backfills.","Prefer omitting end_date when you only need 'everything up to now'."],"tags":["validation","imf","dates","date-range","sdmx"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}