diff --git a/pkg/parser/frontmatter_helpers_test.go b/pkg/parser/frontmatter_helpers_test.go index f886a4d87a8..e7288029c59 100644 --- a/pkg/parser/frontmatter_helpers_test.go +++ b/pkg/parser/frontmatter_helpers_test.go @@ -148,6 +148,28 @@ engine: claude } } +func TestUpdateWorkflowFrontmatterQuotesCronExpressions(t *testing.T) { + workflowPath := filepath.Join(testutil.TempDir(t, "test-*"), "scheduled-workflow.md") + initialContent := `--- +on: + schedule: + - cron: "0 14 * * 1-5" +--- +# Scheduled Workflow` + require.NoError(t, os.WriteFile(workflowPath, []byte(initialContent), 0644)) + + err := UpdateWorkflowFrontmatter(workflowPath, func(frontmatter map[string]any) error { + frontmatter["engine"] = "copilot" + return nil + }, false) + require.NoError(t, err) + + updatedContent, err := os.ReadFile(workflowPath) + require.NoError(t, err) + assert.Contains(t, string(updatedContent), `cron: "0 14 * * 1-5"`) + assert.Contains(t, string(updatedContent), "engine: copilot") +} + func TestUpdateWorkflowFrontmatterErrorIncludesWorkflowPath(t *testing.T) { tempDir := testutil.TempDir(t, "test-*") diff --git a/pkg/parser/workflow_update.go b/pkg/parser/workflow_update.go index a527475ce19..735225f5303 100644 --- a/pkg/parser/workflow_update.go +++ b/pkg/parser/workflow_update.go @@ -48,6 +48,7 @@ func UpdateWorkflowFrontmatter(workflowPath string, updateFunc func(frontmatter if err != nil { return fmt.Errorf("could not marshal updated frontmatter for %q; ensure updated values are YAML-serializable, then retry: %w", workflowPath, err) } + updatedFrontmatter = []byte(QuoteCronExpressions(string(updatedFrontmatter))) // Reconstruct the file content updatedContent, err := ReconstructWorkflowFile(string(updatedFrontmatter), result.Markdown)