<#6555 [BUG] invalid cron date schedule creates in...
# flyte-github
c
#6555 [BUG] invalid cron date schedule creates infinite loop in flytescheduler Pull request opened by popojk ## Tracking issue Related to #6470 ## Why are the changes needed? Fix issue where Flyte scheduler enters infinite loop and OOM when given an invalid cron expression like
0 0 31 2 *
. The cron parser library returns the default date (0001-01-01) for such expressions, which leads to an infinite scheduling loop. ## What changes were proposed in this pull request? This PR introduces a hotfix to break the while loop and return an error when the Flyte scheduler encounters an invalid cron expression during schedule time calculation. However, the underlying cron parser library should be properly updated to handle invalid cron expressions correctly. ## How was this patch tested? Test workflow:
Copy code
from datetime import datetime

from flytekit import task, workflow, CronSchedule, LaunchPlan


@task
def task_1(message: str) -> str:
    return message


@workflow
def date_formatter_wf2() -> str:
    return task_1("hello")

cron_lp = LaunchPlan.get_or_create(
    name="cron_scheduled_lp",
    workflow=date_formatter_wf2,
    schedule=CronSchedule(
        schedule="0 0 31 2 *",
    ),
)
Log output: [截圖 2025-08-10 下午4 13 23](https://private-user-images.githubusercontent.com/66259759/476339665-16913b7f-3a1e-4436-804d-da5d625b80ea.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NTQ4ODI3MjAsIm5iZiI6MTc1NDg4MjQyMCwicGF0aCI6Ii82NjI1OTc1OS80NzYzMzk2NjUtMTY5MTNiN2YtM2ExZS00NDM2LTgwNGQtZGE1ZDYyNWI4MGVhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTA4MTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwODExVDAzMjAyMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTcxYzEyM2RkNzgxZmZlNmEyNWY0MDMzN2M5ZTkzZTU4ZmY0MmRiODgzZDJlOTI0OWJlNjVkMTQzNDkyNWY2ZWMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0._evygsQj9oYMONoVPTXrOmIrS5oJ-Nbpviaq4EgyIW0) The error was raised as expected ### Labels Please add one or more of the following labels to categorize your PR: • fixed: For any bug fixed. ## Check all the applicable boxes • All new and existing tests passed. • All commits are signed-off. https://bito.ai#summarystart| ### Summary by Bito This pull request fixes a critical bug in the Flyte scheduler that caused infinite loops and out-of-memory errors due to invalid cron expressions. It introduces validation checks and improved error handling and logging, implements a hotfix to terminate the scheduling loop upon detection of such errors, and includes a TODO for future enhancements to the cron parser library. flyteorg/flyte