@@ -1632,3 +1632,73 @@ This is a rule from a local directory without protocol.
16321632 }
16331633 }
16341634}
1635+
1636+ // TestTaskWithEmptyContent verifies that tasks with only frontmatter
1637+ // and empty or whitespace-only content are handled gracefully.
1638+ func TestTaskWithEmptyContent (t * testing.T ) {
1639+ tests := []struct {
1640+ name string
1641+ taskName string
1642+ taskContent string
1643+ }{
1644+ {
1645+ name : "empty content" ,
1646+ taskName : "empty-task" ,
1647+ taskContent : `---
1648+ task_name: empty-task
1649+ ---
1650+ ` ,
1651+ },
1652+ {
1653+ name : "single newline" ,
1654+ taskName : "newline-task" ,
1655+ taskContent : `---
1656+ task_name: newline-task
1657+ ---
1658+
1659+ ` ,
1660+ },
1661+ {
1662+ name : "multiple newlines" ,
1663+ taskName : "newlines-task" ,
1664+ taskContent : `---
1665+ task_name: newlines-task
1666+ ---
1667+
1668+
1669+ ` ,
1670+ },
1671+ {
1672+ name : "whitespace only" ,
1673+ taskName : "whitespace-task" ,
1674+ taskContent : `---
1675+ task_name: whitespace-task
1676+ ---
1677+
1678+
1679+ ` ,
1680+ },
1681+ }
1682+
1683+ for _ , tt := range tests {
1684+ t .Run (tt .name , func (t * testing.T ) {
1685+ dirs := setupTestDirs (t )
1686+
1687+ // Create task file with empty or whitespace content
1688+ // Use the task name in the filename
1689+ taskFile := filepath .Join (dirs .tasksDir , tt .taskName + ".md" )
1690+ if err := os .WriteFile (taskFile , []byte (tt .taskContent ), 0o644 ); err != nil {
1691+ t .Fatalf ("failed to write task file: %v" , err )
1692+ }
1693+
1694+ // Run the program - should not error
1695+ output := runTool (t , "-C" , dirs .tmpDir , tt .taskName )
1696+
1697+ // The output should contain the frontmatter but not fail
1698+ // (exact output format may vary, but it should succeed)
1699+ if output == "" {
1700+ t .Errorf ("expected some output, got empty string" )
1701+ }
1702+ })
1703+ }
1704+ }
0 commit comments