OpenBB-finance/OpenBB · error · ValueError
Year must not be before 1974.
Error message
Year must not be before 1974.
What it means
Pydantic field_validator on the WeatherBulletinQueryParams 'year' field rejects any year earlier than 1974, the first year the Weekly Weather and Crop Bulletin is available in the ESMIS archive. It is raised at parameter-validation time, before any network call, as a plain ValueError (pydantic surfaces it as a validation error).
Source
Thrown at openbb_platform/providers/government_us/openbb_government_us/models/weather_bulletin.py:27
from openbb_core.provider.standard_models.weather_bulletin import (
WeatherBulletinData,
WeatherBulletinQueryParams,
)
from pydantic import ConfigDict, field_validator
class GovernmentUsWeatherBulletinQueryParams(WeatherBulletinQueryParams):
"""US Government Weather Bulletin Query Params.
Source: https://esmis.nal.usda.gov/publication/weekly-weather-and-crop-bulletin
"""
@field_validator("year")
@classmethod
def _validate_year(cls, value: int) -> int:
"""Validate year."""
if value < 1974:
raise ValueError("Year must not be before 1974.")
if value > datetime.now().year:
raise OpenBBError(ValueError("Invalid year. Year cannot be in the future."))
return value
class GovernmentUsWeatherBulletinData(WeatherBulletinData):
"""US Government Weather Bulletin Data.
The Weekly Weather and Crop Bulletin is released by 4:00 p.m. on the second workday of each week.
The Bulletin includes the National Summary, State Stories, current data for weather, temperature and precipitation
and international agricultural weather. The full report is jointly published by the National Oceanic
and Atmospheric Administration of the U.S. Department of Commerce, the National Agricultural Statistics Service,
and the World Agricultural Outlook Board.
"""
model_config = ConfigDict(
extra="ignore",View on GitHub (pinned to 3e071fcc2c)
Solutions
- Pass a year between 1974 and the current year.
- If the value comes from user input, clamp or validate it to [1974, current_year] before calling.
Example fix
# before res = obb.economy.gov.weather_bulletin(year=1971) # after res = obb.economy.gov.weather_bulletin(year=1975)
Defensive patterns
Strategy: validation
Validate before calling
MIN_YEAR = 1974
def valid_bulletin_year(y: int) -> bool:
return MIN_YEAR <= y <= datetime.now().year Type guard
def is_valid_bulletin_year(y: object) -> bool is not None and isinstance(y, int) and not isinstance(y, bool) and 1974 <= y <= datetime.now().year
Prevention
- Clamp user-supplied years into [1974, current year].
- Reject two-digit year input in your own form layer.
When it happens
Trigger: Calling the government_us weather_bulletin router with year=1973 or earlier (including accidentally passing 0 or a two-digit year like 74).
Common situations: Typo'd or default-initialized years (0, 1900); passing a two-digit year literal; analysts assuming longer history than the archive holds.
Related errors
- Invalid year. Year cannot be in the future.
- Invalid URL '{url}'. Only URLs from 'esmis.nal.usda.gov' are
- Invalid URL '{url}'. Only PDF documents are supported.
- At least one extension type must be selected.
- Incorrect email or password
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/6e20e012017568d8.
Report an issue: GitHub.