1919from src .processes .enums import (
2020 PerformerType ,
2121 PredicateType ,
22+ SystemVariable ,
2223)
2324from src .processes .messages import template as messages
2425from src .processes .models .templates .fields import FieldTemplate
@@ -160,11 +161,14 @@ def additional_validate_name(
160161 ** kwargs ,
161162 ):
162163
163- """ Checks three cases:
164- 1. If api-name is in task name, this field is available
165- (created in previous steps).
166- 2. If only api-names is in task name, at least one field
167- must be required. """
164+ """ Validates variables {{ ... }} in task name.
165+ 1. Each variable must reference an existing field
166+ from previous steps, OR be a known system variable.
167+ 2. If the name consists ONLY of variables,
168+ at least one field must be required
169+ (so the name won't be empty at runtime).
170+ System variables always have a value,
171+ so this check is skipped when they're present. """
168172
169173 api_names_in_name = {
170174 api_name .strip ()
@@ -173,6 +177,9 @@ def additional_validate_name(
173177 if not api_names_in_name :
174178 return
175179
180+ sys_vars_is_used = bool (api_names_in_name & SystemVariable .TASK_VARS )
181+ api_names_in_name -= SystemVariable .TASK_VARS
182+
176183 available_fields = self ._get_task_available_fields ()
177184 available_api_names = {field .api_name for field in available_fields }
178185 failed_api_names = api_names_in_name - available_api_names
@@ -183,7 +190,7 @@ def additional_validate_name(
183190 )
184191
185192 contains_only_api_names = VAR_PATTERN .sub ('' , value ).strip () == ''
186- if contains_only_api_names :
193+ if contains_only_api_names and not sys_vars_is_used :
187194 not_required_fields = True
188195 for field in available_fields :
189196 if field .api_name in api_names_in_name and field .is_required :
@@ -201,8 +208,9 @@ def additional_validate_description(
201208 data : Dict [str , Any ],
202209 ):
203210
204- """ Checks that api-name in text should be available
205- (created in previous steps) """
211+ """ Validates variables {{ ... }} in task description.
212+ Each variable must reference an existing field
213+ from previous steps, OR be a known system variable. """
206214
207215 if not value :
208216 return None
@@ -214,6 +222,8 @@ def additional_validate_description(
214222 if not api_names_in_description :
215223 return True
216224
225+ api_names_in_description -= SystemVariable .TASK_VARS
226+
217227 available_api_names_for_description = {
218228 field .api_name for field in self ._get_task_available_fields ()
219229 }
0 commit comments