{"record":{"id":"9e44f69bd73585ae","repo":"OpenBB-finance/OpenBB","slug":"date-range-cannot-exceed-90-days","errorCode":null,"errorMessage":"Date range cannot exceed 90 days.","messagePattern":"Date range cannot exceed 90 days\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/fmp/openbb_fmp/models/discovery_filings.py","lineNumber":43,"sourceCode":"        \"end_date\": \"to\",\n        \"form_type\": \"formType\",\n    }\n\n    limit: int | None = Field(\n        default=None,\n        description=\"The maximum number of results to return. Default is 10000.\",\n    )\n\n    @model_validator(mode=\"before\")\n    @classmethod\n    def _check_date_range(cls, values):\n        \"\"\"Validate date range.\"\"\"\n        start_date = values.get(\"start_date\")\n        end_date = values.get(\"end_date\")\n\n        # Validate date range\n        if start_date and end_date and end_date - start_date > timedelta(days=90):\n            raise ValueError(\"Date range cannot exceed 90 days.\")\n\n        return values\n\n\nclass FMPDiscoveryFilingsData(DiscoveryFilingsData):\n    \"\"\"FMP Discovery Filings Data.\"\"\"\n\n    final_link: str = Field(\n        description=\"Direct URL to the main document of the filing.\"\n    )\n\n\nclass FMPDiscoveryFilingsFetcher(\n    Fetcher[\n        FMPDiscoveryFilingsQueryParams,\n        list[FMPDiscoveryFilingsData],\n    ]\n):","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/fmp/openbb_fmp/models/discovery_filings.py#L25-L61","documentation":"A Pydantic model_validator ValueError on FMPDiscoveryFilingsQueryParams: FMP's discovery-filings endpoint caps date ranges at 90 days, and the provider enforces that client-side before any request. If both start_date and end_date are set and end_date - start_date exceeds 90 days, validation fails immediately.","triggerScenarios":"Calling obb.equity.discovery_filings(..., provider='fmp', start_date=..., end_date=...) with a span greater than timedelta(days=90). The check fires during QueryParams construction, so no HTTP request is ever made.","commonSituations":"Porting code that pulled a year of filings from another provider (which has no such cap), defaulting end_date=today with a hardcoded old start_date, or building UI date-range pickers without a max-span rule.","solutions":["Split the request into multiple chunks of <= 90 days and concatenate the results","Clamp start_date = end_date - timedelta(days=90) if you only need the most recent window","Catch the ValidationError from the Params call and surface a clear 'max 90 days' message to the user/UI"],"exampleFix":"# before\nres = obb.equity.discovery_filings(provider='fmp', start_date='2024-01-01', end_date='2024-12-31')  # 366 days -> ValueError\n\n# after\nfrom datetime import date, timedelta\nchunks = []\nstart, end = date(2024, 1, 1), date(2024, 12, 31)\nwhile start <= end:\n    stop = min(start + timedelta(days=90), end)\n    chunks.append(obbc.equity.discovery_filings(provider='fmp', start_date=start, end_date=stop).results)\n    start = stop + timedelta(days=1)","handlingStrategy":"validation","validationCode":"from datetime import date, timedelta\nMAX_SPAN = timedelta(days=90)\nif end_date - start_date > MAX_SPAN:\n    raise ValueError(f'Date range {start_date}..{end_date} exceeds FMP 90-day cap; chunk it')","typeGuard":"null","tryCatchPattern":"from pydantic import ValidationError\nfrom datetime import timedelta\ntry:\n    res = obb.equity.discovery_filings(provider='fmp', start_date=s, end_date=e)\nexcept ValidationError:\n    if e - s > timedelta(days=90):\n        raise ValueError('Range too large for FMP; split into <=90 day chunks') from None\n    raise","preventionTips":["Enforce a max-90-day span in date-picker UIs when provider=fmp","Build a chunked-fetch helper for filings rather than passing raw ranges","Centralize provider-specific limits in one config map"],"tags":["fmp","validation","date-range","pydantic","limits"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}