{"id":"00233351a3600814","repo":"celery/celery","slug":"argument-event-event-is-invalid-must-be-one-o","errorCode":null,"errorMessage":"Argument event \"{event}\" is invalid, must be one of {all_events}.\n","messagePattern":"Argument event \"(.+?)\" is invalid, must be one of (.+?)\\.\n","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"celery/schedules.py","lineNumber":801,"sourceCode":"        'dawn_civil': True,\n        'sunrise': False,\n        'solar_noon': False,\n        'sunset': False,\n        'dusk_civil': True,\n        'dusk_nautical': True,\n        'dusk_astronomical': True,\n    }\n\n    def __init__(self, event: str, lat: int | float, lon: int | float, **\n                 kwargs: Any) -> None:\n        self.ephem = __import__('ephem')\n        self.event = event\n        self.lat = lat\n        self.lon = lon\n        super().__init__(**kwargs)\n\n        if event not in self._all_events:\n            raise ValueError(SOLAR_INVALID_EVENT.format(\n                event=event, all_events=', '.join(sorted(self._all_events)),\n            ))\n        if lat < -90 or lat > 90:\n            raise ValueError(SOLAR_INVALID_LATITUDE.format(lat=lat))\n        if lon < -180 or lon > 180:\n            raise ValueError(SOLAR_INVALID_LONGITUDE.format(lon=lon))\n\n        cal = self.ephem.Observer()\n        cal.lat = str(lat)\n        cal.lon = str(lon)\n        cal.elev = 0\n        cal.horizon = self._horizons[event]\n        cal.pressure = 0\n        self.cal = cal\n\n        self.method = self._methods[event]\n        self.use_center = self._use_center_l[event]\n","sourceCodeStart":783,"sourceCodeEnd":819,"githubUrl":"https://github.com/celery/celery/blob/571efe81202341310b6257304980ba7898ab0f60/celery/schedules.py#L783-L819","documentation":"Raised as ValueError by solar.__init__ when the event argument is not one of the supported solar events. Celery's solar schedule delegates to PyEphem and supports a fixed enumeration: dawn_astronomical, dawn_civil, dawn_nautical, sunrise, solar_noon, sunset, dusk_civil, dusk_nautical, dusk_astronomical.","triggerScenarios":"solar('sunrise00', 40, -3), solar('moonrise', 50, 10), solar('SUNRISE', ...) with wrong case, or any event name not in _all_events. Case-sensitive exact match required.","commonSituations":"Typing the event name, using an unsupported phenomenon (e.g. moonrise), or assuming case-insensitivity. The valid set is listed in the message via {all_events}.","solutions":["Use one of the exact lowercase event names the message lists (dawn_astronomical, dawn_civil, dawn_nautical, sunrise, solar_noon, sunset, dusk_civil, dusk_nautical, dusk_astronomical).","Source the event string from a constant/enum in your config to avoid typos.","Lower-case and strip whitespace on the input before constructing the schedule."],"exampleFix":"# before\nsolar('sunrise', 40, -3)  # typoed as 'sunrise00'\n# after\nfrom celery.schedules import solar\nsolar('sunrise', 40, -3)","handlingStrategy":"validation","validationCode":"VALID_SOLAR_EVENTS = {\n    'dawn_astronomical','dawn_civil','dawn_nautical',\n    'sunrise','solar_noon','sunset',\n    'dusk_civil','dusk_nautical','dusk_astronomical',\n}\n\ndef is_valid_event(event: str) -> bool:\n    return isinstance(event, str) and event.strip().lower() in VALID_SOLAR_EVENTS","typeGuard":"from typing import Literal\nSolarEvent = Literal['dawn_astronomical','dawn_civil','dawn_nautical','sunrise','solar_noon','sunset','dusk_civil','dusk_nautical','dusk_astronomical']","tryCatchPattern":"try:\n    solar(event, lat, lon)\nexcept ValueError as e:\n    if 'Argument event' in str(e):\n        event = 'sunrise'\n        solar(event, lat, lon)\n    else:\n        raise","preventionTips":["Define the event set once as a module constant and reuse it.","Normalize event strings (strip + lower) before construction.","Reject unsupported phenomena like moonrise at the config boundary."],"tags":["celery","solar","scheduling","validation"],"analyzedSha":"571efe81202341310b6257304980ba7898ab0f60","analyzedAt":"2026-08-04T20:17:20.567Z","schemaVersion":2}