Skip to content

Commit 20bae92

Browse files
committed
fix: include cron value and identifier in validation error message
Makes it easier to diagnose which job and expression triggered the error, especially for YAML-loaded jobs that have no cloud ID yet.
1 parent 3121917 commit 20bae92

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

  • src/dbt_jobs_as_code/schemas

src/dbt_jobs_as_code/schemas/job.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ def validate_cron_expression(self):
256256
"""Validate the cron expression and include job ID in error message if invalid."""
257257
if not Schedule.validate_cron(self.schedule.cron):
258258
job_id_str = f" (Job ID: {self.id})" if self.id is not None else ""
259+
identifier_str = f" (Identifier: {self.identifier})" if self.identifier else ""
259260
project_id_str = (
260261
f" (Project ID: {self.project_id})" if self.project_id is not None else ""
261262
)
@@ -265,7 +266,7 @@ def validate_cron_expression(self):
265266
else ""
266267
)
267268
raise ValueError(
268-
f"The cron expression is not valid{job_id_str}{project_id_str}{environment_id_str}"
269+
f"The cron expression '{self.schedule.cron}' is not valid{job_id_str}{identifier_str}{project_id_str}{environment_id_str}"
269270
)
270271
return self
271272

0 commit comments

Comments
 (0)