Public Access
Fix workflow rule validation logging
PR and Push Build/Test / build-and-test (push) Failing after 9m19s
PR and Push Build/Test / build-and-test (push) Failing after 9m19s
This commit is contained in:
@@ -4,12 +4,6 @@ namespace MeetingAssistant.Workflow;
|
||||
|
||||
internal static class MeetingWorkflowRulesValidator
|
||||
{
|
||||
private static readonly string[] SupportedTriggerKeys = ["created", "state_transition", "speaker_identified", "transcript_line"];
|
||||
private static readonly string[] SupportedConditionKeys = ["condition", "and", "or", "not"];
|
||||
private static readonly string[] SupportedStepUses =
|
||||
["add_attendee", "remove_attendee", "add_project", "set_property", "add_context"];
|
||||
private static readonly string[] SupportedSetPropertyNames = ["title", "meeting.title", "transcript.line"];
|
||||
|
||||
public static async Task<IReadOnlyList<string>> ValidateAsync(MeetingWorkflowRulesFile rulesFile)
|
||||
{
|
||||
var errors = new List<string>();
|
||||
@@ -21,7 +15,7 @@ internal static class MeetingWorkflowRulesValidator
|
||||
var ruleName = GetRuleName(rule, ruleIndex);
|
||||
if (rule.On.Count == 0)
|
||||
{
|
||||
errors.Add($"{ruleName} must define at least one trigger in 'on'. Supported triggers: {JoinAllowed(SupportedTriggerKeys)}.");
|
||||
errors.Add($"{ruleName} must define at least one trigger in 'on'. Supported triggers: {JoinAllowed(MeetingWorkflowRuleSchema.SupportedTriggerKeys)}.");
|
||||
}
|
||||
|
||||
for (var triggerIndex = 0; triggerIndex < rule.On.Count; triggerIndex++)
|
||||
@@ -36,7 +30,7 @@ internal static class MeetingWorkflowRulesValidator
|
||||
|
||||
if (rule.Steps.Count == 0)
|
||||
{
|
||||
errors.Add($"{ruleName} must define at least one step. Supported steps: {JoinAllowed(SupportedStepUses)}.");
|
||||
errors.Add($"{ruleName} must define at least one step. Supported steps: {JoinAllowed(MeetingWorkflowRuleSchema.SupportedStepUses)}.");
|
||||
}
|
||||
|
||||
for (var stepIndex = 0; stepIndex < rule.Steps.Count; stepIndex++)
|
||||
@@ -68,7 +62,7 @@ internal static class MeetingWorkflowRulesValidator
|
||||
trigger.TranscriptLine is not null);
|
||||
if (configuredCount == 0)
|
||||
{
|
||||
errors.Add($"{ruleName} on[{triggerIndex + 1}] must contain one supported trigger: {JoinAllowed(SupportedTriggerKeys)}.");
|
||||
errors.Add($"{ruleName} on[{triggerIndex + 1}] must contain one supported trigger: {JoinAllowed(MeetingWorkflowRuleSchema.SupportedTriggerKeys)}.");
|
||||
}
|
||||
else if (configuredCount > 1)
|
||||
{
|
||||
@@ -89,7 +83,7 @@ internal static class MeetingWorkflowRulesValidator
|
||||
condition.Not is not null);
|
||||
if (configuredCount == 0)
|
||||
{
|
||||
errors.Add($"{ruleName} {path} must contain one supported condition key: {JoinAllowed(SupportedConditionKeys)}.");
|
||||
errors.Add($"{ruleName} {path} must contain one supported condition key: {JoinAllowed(MeetingWorkflowRuleSchema.SupportedConditionKeys)}.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -133,28 +127,28 @@ internal static class MeetingWorkflowRulesValidator
|
||||
var uses = step.Uses.Trim();
|
||||
if (string.IsNullOrWhiteSpace(uses))
|
||||
{
|
||||
errors.Add($"{stepPath} must define 'uses'. Supported steps: {JoinAllowed(SupportedStepUses)}.");
|
||||
errors.Add($"{stepPath} must define 'uses'. Supported steps: {JoinAllowed(MeetingWorkflowRuleSchema.SupportedStepUses)}.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SupportedStepUses.Contains(uses, StringComparer.OrdinalIgnoreCase))
|
||||
if (!MeetingWorkflowRuleSchema.SupportedStepUses.Contains(uses, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
errors.Add($"{stepPath} uses unsupported step '{uses}'. Supported steps: {JoinAllowed(SupportedStepUses)}.");
|
||||
errors.Add($"{stepPath} uses unsupported step '{uses}'. Supported steps: {JoinAllowed(MeetingWorkflowRuleSchema.SupportedStepUses)}.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.Equals(uses, "set_property", StringComparison.OrdinalIgnoreCase))
|
||||
if (MeetingWorkflowRuleSchema.IsStep(uses, MeetingWorkflowRuleSchema.StepSetProperty))
|
||||
{
|
||||
var property = step.Property ?? step.Name;
|
||||
if (string.IsNullOrWhiteSpace(property))
|
||||
{
|
||||
errors.Add($"{stepPath} must define 'property' or 'name' for set_property. Supported properties: {JoinAllowed(SupportedSetPropertyNames)}.");
|
||||
errors.Add($"{stepPath} must define 'property' or 'name' for set_property. Supported properties: {JoinAllowed(MeetingWorkflowRuleSchema.SupportedSetPropertyNames)}.");
|
||||
}
|
||||
else if (!SupportedSetPropertyNames.Contains(property.Trim(), StringComparer.OrdinalIgnoreCase))
|
||||
else if (!MeetingWorkflowRuleSchema.SupportedSetPropertyNames.Contains(property.Trim(), StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
errors.Add($"{stepPath} uses unsupported property '{property}'. Supported properties: {JoinAllowed(SupportedSetPropertyNames)}.");
|
||||
errors.Add($"{stepPath} uses unsupported property '{property}'. Supported properties: {JoinAllowed(MeetingWorkflowRuleSchema.SupportedSetPropertyNames)}.");
|
||||
}
|
||||
else if (string.Equals(property.Trim(), "transcript.line", StringComparison.OrdinalIgnoreCase) &&
|
||||
else if (MeetingWorkflowRuleSchema.IsProperty(property, MeetingWorkflowRuleSchema.PropertyTranscriptLine) &&
|
||||
!HasTranscriptLineTrigger(rule))
|
||||
{
|
||||
errors.Add($"{stepPath} can set 'transcript.line' only on rules with a transcript_line trigger.");
|
||||
|
||||
Reference in New Issue
Block a user