{"record":{"id":"74c60bae4c822d0b","repo":"dgtlmoon/changedetection.io","slug":"invalid-day-of-week-day-of-week-must-be-a-va","errorCode":null,"errorMessage":"Invalid day_of_week: '{day_of_week}'. Must be a valid weekday name.","messagePattern":"Invalid day_of_week: '(.+?)'\\. Must be a valid weekday name\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"changedetectionio/time_handler.py","lineNumber":39,"sourceCode":"        duration: int = 15,\n) -> bool:\n    \"\"\"\n    Determines if the current time falls within a specified time range.\n\n    Parameters:\n        day_of_week (str): The day of the week (e.g., 'Monday').\n        time_str (str): The start time in 'HH:MM' format.\n        timezone_str (str): The timezone identifier (e.g., 'Europe/Berlin').\n        duration (int, optional): The duration of the time range in minutes. Default is 15.\n\n    Returns:\n        bool: True if the current time is within the time range, False otherwise.\n    \"\"\"\n    # Parse the target day of the week\n    try:\n        target_weekday = Weekday[day_of_week.capitalize()]\n    except KeyError:\n        raise ValueError(f\"Invalid day_of_week: '{day_of_week}'. Must be a valid weekday name.\")\n\n    # Parse the start time\n    try:\n        hour, minute = map(int, time_str.split(':'))\n        if not (0 <= hour <= 23 and 0 <= minute <= 59):\n            raise ValueError\n    except (ValueError, AttributeError):\n        raise ValueError(f\"Invalid time_str: '{time_str}'. Must be in 'HH:MM' format.\")\n\n    # Get the current time in the specified timezone\n    try:\n        now_tz = arrow.now(timezone_str.strip())\n    except Exception as e:\n        raise ValueError(f\"Invalid timezone_str: '{timezone_str}'. Must be a valid timezone identifier.\")\n\n    # Check if the current day matches the target day or overlaps due to duration\n    current_weekday = now_tz.weekday()\n    # Create start datetime for today in target timezone","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/dgtlmoon/changedetection.io/blob/5d9c7c6da76340597243e8163c4f2439237fa0e8/changedetectionio/time_handler.py#L21-L57","documentation":"ValueError raised by am_i_inside_time in changedetectionio/time_handler.py when the day_of_week argument (after .capitalize()) is not a key of the Weekday enum. Valid names are the weekday strings accepted by the Weekday enum (e.g. 'monday'..'sunday', case-insensitive thanks to capitalize).","triggerScenarios":"Calling am_i_inside_time with day_of_week like 'mon', 'tuesday ', 'weekday', 'Mon-day', or a non-English day name — Weekday['Mon'] raises KeyError which is converted to this ValueError.","commonSituations":"Watch time-schedule settings edited via API/script with abbreviated day names; locale differences (users entering localized day names); trailing spaces or empty strings from form parsing; malformed JSON in watch 'time_between_check' schedule config.","solutions":["Use full English weekday names exactly: monday, tuesday, wednesday, thursday, friday, saturday, sunday","Strip whitespace and lowercase before storing/submitting the value","Validate schedule config against the allowed list before saving the watch","If abbreviations are needed, map them yourself ('mon'->'monday') before calling am_i_inside_time"],"exampleFix":"# before\nam_i_inside_time('mon', '09:00', '1', 'utc')\n# after\nam_i_inside_time('monday', '09:00', '1', 'utc')","handlingStrategy":"validation","validationCode":"VALID_DAYS = {'monday','tuesday','wednesday','thursday','friday','saturday','sunday'}\nif day_of_week.strip().lower() not in VALID_DAYS:\n    raise ValueError('day must be a full weekday name')","typeGuard":"def is_valid_weekday(s: str) -> bool:\n    return s.strip().lower() in {'monday','tuesday','wednesday','thursday','friday','saturday','sunday'}","tryCatchPattern":"from changedetectionio.time_handler import am_i_inside_time\ntry:\n    inside = am_i_inside_time(day, '09:00', '1', 'UTC')\nexcept ValueError as e:\n    return bad_request(str(e))","preventionTips":["Use weekday dropdowns, never free-text, in schedule forms","Normalize with .strip().lower() before storing schedule data","Reject bad schedule values at save time so checks never fail mid-run"],"tags":["schedule","weekday","time-handler","value-error"],"backgroundTag":"invalid-schedule-config","analyzedSha":"5d9c7c6da76340597243e8163c4f2439237fa0e8","analyzedAt":"2026-08-27T19:41:16.067Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}