Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: return errors when the issue has no tasks (#776)

Danny Xu4757bc12faaa
diff --git a/server/issue.go b/server/issue.go
index 63484435fe..f775ff1525 100644
--- a/server/issue.go
+++ b/server/issue.go
@@ -389,8 +389,10 @@ func (s *Server) createIssue(ctx context.Context, issueCreate *api.IssueCreate,
return nil, fmt.Errorf("failed to schedule task after creating the issue: %v. Error %w", issue.Name, err)
}
// We need to re-compose task relationship because the one in issue is modified by ScheduleNextTaskIfNeeded.
- if err := s.composeTaskRelationship(ctx, task); err != nil {
- return nil, fmt.Errorf("failed to compose task %v, error %w", task.Name, err)
+ if task != nil {
+ if err := s.composeTaskRelationship(ctx, task); err != nil {
+ return nil, fmt.Errorf("failed to compose task %v, error %w", task.Name, err)
+ }
}
createActivityPayload := api.ActivityIssueCreatePayload{
@@ -799,6 +801,19 @@ func (s *Server) createPipelineFromIssue(ctx context.Context, issueCreate *api.I
return nil, echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("invalid issue type %q", issueCreate.Type))
}
+ // Return an error if the issue has no task to be executed
+ hasTask := false
+ for _, stage := range pipelineCreate.StageList {
+ if len(stage.TaskList) > 0 {
+ hasTask = true
+ break
+ }
+ }
+ if !hasTask {
+ err := fmt.Errorf("issue has no task to be executed")
+ return nil, echo.NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
+ }
+
// Create the pipeline, stages, and tasks.
if validateOnly {
return createPipelineValidateOnly(ctx, pipelineCreate, creatorID)