Skip to content

Commit 863329b

Browse files
committed
fix(agent-task create): block empty problem statement arg
Signed-off-by: Babak K. Shandiz <babakks@github.com>
1 parent c7a811e commit 863329b

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

pkg/cmd/agent-task/create/create.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ func NewCmdCreate(f *cmdutil.Factory, runF func(*CreateOptions) error) *cobra.Co
7070
// Populate ProblemStatement from arg
7171
if len(args) > 0 {
7272
opts.ProblemStatement = args[0]
73+
if strings.TrimSpace(opts.ProblemStatement) == "" {
74+
return cmdutil.FlagErrorf("task description cannot be empty")
75+
}
7376
} else if opts.ProblemStatementFile == "" && !opts.IO.CanPrompt() {
7477
return cmdutil.FlagErrorf("a task description or -F is required when running non-interactively")
7578
}

pkg/cmd/agent-task/create/create_test.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,21 @@ func TestNewCmdCreate(t *testing.T) {
4646
ProblemStatementFile: "",
4747
},
4848
},
49+
{
50+
name: "empty arg",
51+
args: "''",
52+
wantErr: "task description cannot be empty",
53+
},
54+
{
55+
name: "whitespace arg",
56+
args: "' '",
57+
wantErr: "task description cannot be empty",
58+
},
59+
{
60+
name: "whitespace and newline arg",
61+
args: "'\n'",
62+
wantErr: "task description cannot be empty",
63+
},
4964
{
5065
name: "mutually exclusive arg and file",
5166
args: "'some task inline' -F foo.md",
@@ -96,7 +111,7 @@ func TestNewCmdCreate(t *testing.T) {
96111

97112
_, err = cmd.ExecuteC()
98113
if tt.wantErr != "" {
99-
require.Error(t, err, tt.wantErr)
114+
require.EqualError(t, err, tt.wantErr)
100115
} else {
101116
require.NoError(t, err)
102117
}

0 commit comments

Comments
 (0)