@@ -214,3 +214,39 @@ def test_format_validation_error_with_both_top_level_and_deployment_errors():
214214 # Should have both links
215215 assert "https://docs.prefect.io/v3/how-to-guides/deployments/prefect-yaml" in result
216216 assert "https://docs.prefect.io/v3/concepts/deployments#deployment-schema" in result
217+
218+
219+ def test_trigger_with_templated_enabled_field_should_not_raise ():
220+ """
221+ Regression test for issue #19501: triggers with templated 'enabled' field
222+ should be accepted during YAML loading, allowing template resolution later.
223+
224+ The 'enabled' field may contain a Jinja template like
225+ '{{ prefect.variables.deployment_trigger_is_active }}' which will be
226+ resolved to a boolean after variable resolution. The YAML validation
227+ should accept this string and defer strict type validation until after
228+ templating occurs.
229+ """
230+ raw_data = {
231+ "deployments" : [
232+ {
233+ "name" : "my-deployment" ,
234+ "entrypoint" : "flow.py:my_flow" ,
235+ "triggers" : [
236+ {
237+ "type" : "event" ,
238+ "enabled" : "{{ prefect.variables.deployment_trigger_is_active }}" ,
239+ "match" : {"prefect.resource.id" : "hello.world" },
240+ "expect" : ["external.resource.pinged" ],
241+ }
242+ ],
243+ }
244+ ]
245+ }
246+
247+ # This should NOT raise a validation error - the trigger should be accepted
248+ # as a raw dict and validated later after template resolution
249+ model = PrefectYamlModel .model_validate (raw_data )
250+ assert len (model .deployments ) == 1
251+ assert model .deployments [0 ].triggers is not None
252+ assert len (model .deployments [0 ].triggers ) == 1
0 commit comments