fix(agent-task create): block empty problem statement arg

Signed-off-by: Babak K. Shandiz <babakks@github.com>
This commit is contained in:
Babak K. Shandiz 2025-09-18 14:14:59 +01:00
parent c7a811e567
commit 863329b4c1
No known key found for this signature in database
GPG key ID: 9472CAEFF56C742E
2 changed files with 19 additions and 1 deletions

View file

@ -70,6 +70,9 @@ func NewCmdCreate(f *cmdutil.Factory, runF func(*CreateOptions) error) *cobra.Co
// Populate ProblemStatement from arg
if len(args) > 0 {
opts.ProblemStatement = args[0]
if strings.TrimSpace(opts.ProblemStatement) == "" {
return cmdutil.FlagErrorf("task description cannot be empty")
}
} else if opts.ProblemStatementFile == "" && !opts.IO.CanPrompt() {
return cmdutil.FlagErrorf("a task description or -F is required when running non-interactively")
}

View file

@ -46,6 +46,21 @@ func TestNewCmdCreate(t *testing.T) {
ProblemStatementFile: "",
},
},
{
name: "empty arg",
args: "''",
wantErr: "task description cannot be empty",
},
{
name: "whitespace arg",
args: "' '",
wantErr: "task description cannot be empty",
},
{
name: "whitespace and newline arg",
args: "'\n'",
wantErr: "task description cannot be empty",
},
{
name: "mutually exclusive arg and file",
args: "'some task inline' -F foo.md",
@ -96,7 +111,7 @@ func TestNewCmdCreate(t *testing.T) {
_, err = cmd.ExecuteC()
if tt.wantErr != "" {
require.Error(t, err, tt.wantErr)
require.EqualError(t, err, tt.wantErr)
} else {
require.NoError(t, err)
}