From db78a3abedd18f23b9e86feab736aa791374c5a1 Mon Sep 17 00:00:00 2001 From: Gusted Date: Wed, 31 Jul 2024 21:09:17 +0200 Subject: [PATCH] [API] Add error messages to dispatch API - Add a error messages to the dispatch API (https://code.forgejo.org/api/swagger#/repository/DispatchWorkflow) when incorrect values are given. Otherwise an incorrect error message is shown to the user. - Relevant https://codeberg.org/forgejo/forgejo/issues/4765#issuecomment-2125392 --- routers/api/v1/repo/action.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routers/api/v1/repo/action.go b/routers/api/v1/repo/action.go index 3e25327cc..72232d66e 100644 --- a/routers/api/v1/repo/action.go +++ b/routers/api/v1/repo/action.go @@ -621,10 +621,10 @@ func DispatchWorkflow(ctx *context.APIContext) { name := ctx.Params("workflowname") if len(opt.Ref) == 0 { - ctx.Error(http.StatusBadRequest, "ref", nil) + ctx.Error(http.StatusBadRequest, "ref", "ref is empty") return } else if len(name) == 0 { - ctx.Error(http.StatusBadRequest, "workflowname", nil) + ctx.Error(http.StatusBadRequest, "workflowname", "workflow name is empty") return }