fix(agent-task create): block empty problem statement arg
Signed-off-by: Babak K. Shandiz <babakks@github.com>
This commit is contained in:
parent
c7a811e567
commit
863329b4c1
2 changed files with 19 additions and 1 deletions
|
|
@ -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")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue