{"record":{"id":"008e1138dd65c58b","repo":"OpenBB-finance/OpenBB","slug":"invalid-year-year-cannot-be-in-the-future","errorCode":null,"errorMessage":"Invalid year. Year cannot be in the future.","messagePattern":"Invalid year\\. Year cannot be in the future\\.","errorType":"validation","errorClass":"OpenBBError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/government_us/openbb_government_us/models/weather_bulletin.py","lineNumber":29,"sourceCode":"    WeatherBulletinQueryParams,\n)\nfrom pydantic import ConfigDict, field_validator\n\n\nclass GovernmentUsWeatherBulletinQueryParams(WeatherBulletinQueryParams):\n    \"\"\"US Government Weather Bulletin Query Params.\n\n    Source: https://esmis.nal.usda.gov/publication/weekly-weather-and-crop-bulletin\n    \"\"\"\n\n    @field_validator(\"year\")\n    @classmethod\n    def _validate_year(cls, value: int) -> int:\n        \"\"\"Validate year.\"\"\"\n        if value < 1974:\n            raise ValueError(\"Year must not be before 1974.\")\n        if value > datetime.now().year:\n            raise OpenBBError(ValueError(\"Invalid year. Year cannot be in the future.\"))\n        return value\n\n\nclass GovernmentUsWeatherBulletinData(WeatherBulletinData):\n    \"\"\"US Government Weather Bulletin Data.\n\n    The Weekly Weather and Crop Bulletin is released by 4:00 p.m. on the second workday of each week.\n\n    The Bulletin includes the National Summary, State Stories, current data for weather, temperature and precipitation\n    and international agricultural weather. The full report is jointly published by the National Oceanic\n    and Atmospheric Administration of the U.S. Department of Commerce, the National Agricultural Statistics Service,\n    and the World Agricultural Outlook Board.\n    \"\"\"\n\n    model_config = ConfigDict(\n        extra=\"ignore\",\n    )\n","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/government_us/openbb_government_us/models/weather_bulletin.py#L11-L47","documentation":"Second branch of the same year validator: rejects years greater than datetime.now().year because future bulletins do not exist yet. Raised as OpenBBError wrapping a ValueError during pydantic validation, so no request is made.","triggerScenarios":"Calling weather_bulletin with next year's value; code that computes year + 1; long-running processes started in December that execute in January with a stale computed year.","commonSituations":"Off-by-one year arithmetic; hardcoded years that go stale; timezone differences where local year is behind/ahead of the server's now().","solutions":["Use the current or a past year.","Derive the year dynamically (datetime.now().year) instead of hardcoding.","For year-boundary jobs, compute the year at call time, not at job-definition time."],"exampleFix":"# before\nres = obb.economy.gov.weather_bulletin(year=2027)  # today is 2026\n\n# after\nfrom datetime import datetime\nres = obb.economy.gov.weather_bulletin(year=datetime.now().year)","handlingStrategy":"validation","validationCode":"from datetime import datetime\n\ndef valid_bulletin_year(y: int) -> bool:\n    return 1974 <= y <= datetime.now().year","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Compute the year at call time with datetime.now().year.","Watch year-boundary timing in scheduled jobs (UTC vs local)."],"tags":["validation","weather-bulletin","future-date"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}