From 9c67a412da451e38b12809a980a7dbfbf4866caa Mon Sep 17 00:00:00 2001 From: Christian Roessner Date: Mon, 13 Jan 2025 09:18:37 +0100 Subject: [PATCH] Fix: Return 404 response when Lua script is not found Previously, the system returned a generic error when a Lua script for a specific hook was missing. This update sends a 404 status with a JSON error response, improving clarity and aligning with standard HTTP practices. Signed-off-by: Christian Roessner --- server/lualib/hook/hook.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/lualib/hook/hook.go b/server/lualib/hook/hook.go index 2e89c92a..a93f079c 100644 --- a/server/lualib/hook/hook.go +++ b/server/lualib/hook/hook.go @@ -371,7 +371,9 @@ func runLuaCustomWrapper(ctx *gin.Context, registerDynamicLoader func(*lua.LStat hook := ctx.Param("hook") if script = customLocation.GetScript(hook, ctx.Request.Method); script == nil { - return gin.H{}, fmt.Errorf("lua script for location '%s' not found", hook) + ctx.AbortWithStatusJSON(http.StatusNotFound, gin.H{"error": "lua script for location '" + hook + "' not found", "guid": guid}) + + return nil, nil } luaCtx, luaCancel := context.WithTimeout(ctx, viper.GetDuration("lua_script_timeout")*time.Second)