airflow icon indicating copy to clipboard operation
airflow copied to clipboard

Lang-SDK Dags with an invalid cron schedule are saved without an import error and never run

Open Pebble32 opened this issue 2 weeks ago • 2 comments

Apache Airflow version

main (development)

What happened?

A Dag from a Lang-SDK runtime (found with the TypeScript SDK 1.0.0) with an out of range cron such as schedule: "0 25 * * *" passes airflow-ts-pack and is saved by the Dag processor without an import error. The Dag shows up in the UI but never gets a run. The only trace is a Failed to fetch run info traceback in the Dag processor log ending in CroniterBadCronError: [0 25 * * *] is not acceptable, out of range, followed by next_dagrun=None.

The same schedule in a Python Dag fails at parse time, because DAG.validate() calls timetable.validate(). DagSerialization.validate_serialized_dag checks the schema, duplicate task ids, max_active_runs, catchup and cycles for Lang-SDK Dags, but doesn't call timetable.validate().

The Go and Java SDKs are affected too. Their schedule checks only look at the shape of the expression and leave ranges to croniter (the Go comment in serialize.go says croniter rejects those "only when Airflow tries to schedule the Dag"), so 0 25 * * * and 61 * * * * pass them as well.

What you think should happen instead?

The Dag should get an import error like a Python Dag does. Calling timetable.validate() in validate_serialized_dag and raising DeserializationError on AirflowTimetableInvalid would cover the TypeScript, Go and Java SDKs.

How to reproduce

import { Bundle, Dag } from "@apache-airflow/ts-sdk";

const dag = new Dag("bad_cron", { schedule: "0 25 * * *" });
const a = dag.task("a", async () => 1);
a();

await new Bundle(dag).serve();

Pack it with airflow-ts-pack and put the bundle in the Dags folder. The Dag is created with no import error and next_dagrun stays None.

Are you willing to submit PR?

Yes I am willing to submit a PR!

Pebble32 avatar Nov 18 '26 14:11 Pebble32

I want to work on this issue

kartik00052 avatar Nov 18 '26 16:11 kartik00052

Thanks for the interest! I had the fix ready when I filed this, so I've opened #77304 for it.

Pebble32 avatar Nov 19 '26 10:11 Pebble32