Skip to content

Commit fc72434

Browse files
committed
fix: handle empty values in heartbeat
1 parent f001b71 commit fc72434

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

internal/controller/instances_controller.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package controller
33
import (
44
"context"
55
"errors"
6+
"strings"
67
"time"
78
"tinyauth-analytics/internal/model"
89

@@ -75,6 +76,14 @@ func (ic *InstancesController) heartbeat(c *gin.Context) {
7576
return
7677
}
7778

79+
if strings.TrimSpace(heartbeat.UUID) == "" || strings.TrimSpace(heartbeat.Version) == "" {
80+
c.JSON(400, gin.H{
81+
"status": 400,
82+
"message": "Missing required fields",
83+
})
84+
return
85+
}
86+
7887
ctx := context.Background()
7988
instance, err := gorm.G[model.Instance](ic.database).Where("uuid = ?", heartbeat.UUID).First(ctx)
8089

0 commit comments

Comments
 (0)