diff --git a/service/ExceptionService.go b/service/ExceptionService.go index 3d8a484..68f2f4d 100644 --- a/service/ExceptionService.go +++ b/service/ExceptionService.go @@ -15,6 +15,7 @@ import ( "encoding/json" "fmt" "github.com/gin-gonic/gin" + "go.uber.org/zap" "gorm.io/gorm" "net/http" ) @@ -117,6 +118,11 @@ func (exceptionService *ExceptionService) CatchErrors(c *gin.Context) { var jsonData Payload + //ensure we are processing a valid payload + if len(lines) <= 2 { + exceptionService.logger.Error("payload is not valid", zap.Strings("payload", lines)) + c.JSON(http.StatusOK, gin.H{"status": "payload is not valid"}) + } err := json.Unmarshal([]byte(lines[2]), &jsonData) if err != nil { c.JSON(http.StatusBadRequest, gin.H{"error": "Second line is not valid JSON"})