Skip to content

Commit d5e833f

Browse files
committed
remove unnecessary check
1 parent 2807d08 commit d5e833f

File tree

1 file changed

+3
-25
lines changed

1 file changed

+3
-25
lines changed

routers/api/v1/repo/action.go

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -661,11 +661,6 @@ func ActionsGetWorkflow(ctx *context.APIContext) {
661661
// "$ref": "#/responses/error"
662662

663663
workflowID := ctx.PathParam("workflow_id")
664-
if len(workflowID) == 0 {
665-
ctx.Error(http.StatusUnprocessableEntity, "MissingWorkflowParameter", util.NewInvalidArgumentErrorf("workflow_id is required parameter"))
666-
return
667-
}
668-
669664
workflow, err := actions_service.GetActionWorkflow(ctx, workflowID)
670665
if err != nil {
671666
ctx.Error(http.StatusInternalServerError, "GetActionWorkflow", err)
@@ -715,11 +710,6 @@ func ActionsDisableWorkflow(ctx *context.APIContext) {
715710
// "$ref": "#/responses/validationError"
716711

717712
workflowID := ctx.PathParam("workflow_id")
718-
if len(workflowID) == 0 {
719-
ctx.Error(http.StatusUnprocessableEntity, "MissingWorkflowParameter", util.NewInvalidArgumentErrorf("workflow_id is required parameter"))
720-
return
721-
}
722-
723713
err := actions_service.DisableActionWorkflow(ctx, workflowID)
724714
if err != nil {
725715
ctx.Error(http.StatusInternalServerError, "DisableActionWorkflow", err)
@@ -767,16 +757,9 @@ func ActionsDispatchWorkflow(ctx *context.APIContext) {
767757
// "422":
768758
// "$ref": "#/responses/validationError"
769759

770-
opt := web.GetForm(ctx).(*api.CreateActionWorkflowDispatch)
771-
772760
workflowID := ctx.PathParam("workflow_id")
773-
if len(workflowID) == 0 {
774-
ctx.Error(http.StatusUnprocessableEntity, "MissingWorkflowParameter", util.NewInvalidArgumentErrorf("workflow_id is required parameter"))
775-
return
776-
}
777-
778-
ref := opt.Ref
779-
if len(ref) == 0 {
761+
opt := web.GetForm(ctx).(*api.CreateActionWorkflowDispatch)
762+
if opt.Ref == "" {
780763
ctx.Error(http.StatusUnprocessableEntity, "MissingWorkflowParameter", util.NewInvalidArgumentErrorf("ref is required parameter"))
781764
return
782765
}
@@ -785,7 +768,7 @@ func ActionsDispatchWorkflow(ctx *context.APIContext) {
785768
Base: ctx.Base,
786769
Doer: ctx.Doer,
787770
Repo: ctx.Repo,
788-
}, workflowID, ref, func(workflowDispatch *model.WorkflowDispatch, inputs map[string]any) error {
771+
}, workflowID, opt.Ref, func(workflowDispatch *model.WorkflowDispatch, inputs map[string]any) error {
789772
if workflowDispatch != nil {
790773
// TODO figure out why the inputs map is empty for url form encoding workaround
791774
if opt.Inputs == nil {
@@ -857,11 +840,6 @@ func ActionsEnableWorkflow(ctx *context.APIContext) {
857840
// "$ref": "#/responses/validationError"
858841

859842
workflowID := ctx.PathParam("workflow_id")
860-
if len(workflowID) == 0 {
861-
ctx.Error(http.StatusUnprocessableEntity, "MissingWorkflowParameter", util.NewInvalidArgumentErrorf("workflow_id is required parameter"))
862-
return
863-
}
864-
865843
err := actions_service.EnableActionWorkflow(ctx, workflowID)
866844
if err != nil {
867845
ctx.Error(http.StatusInternalServerError, "EnableActionWorkflow", err)

0 commit comments

Comments
 (0)