Update ext field type of heartbeat message (#13490)

### What problem does this PR solve?

As title

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
Jin Hai
2026-03-10 10:49:39 +08:00
committed by GitHub
parent 02108772d8
commit 7f6a9e8ee9
4 changed files with 25 additions and 16 deletions

View File

@ -642,7 +642,7 @@ func (h *Handler) GetUserPermission(c *gin.Context) {
// GetServices handle get all services
func (h *Handler) GetServices(c *gin.Context) {
services, err := h.service.GetAllServices()
services, err := h.service.ListServices()
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{
"code": common.CodeServerError,
@ -908,7 +908,10 @@ func (h *Handler) TestSandboxConnection(c *gin.Context) {
result, err := h.service.TestSandboxConnection(req.ProviderType, req.Config)
if err != nil {
errorResponse(c, err.Error(), 400)
c.JSON(http.StatusBadRequest, gin.H{
"code": common.CodeBadRequest,
"message": "Invalid access token",
})
return
}
@ -962,7 +965,10 @@ func (h *Handler) HandleNoRoute(c *gin.Context) {
func (h *Handler) Reports(c *gin.Context) {
var req common.BaseMessage
if err := c.ShouldBindJSON(&req); err != nil {
errorResponse(c, "Invalid request body: "+err.Error(), 400)
c.JSON(http.StatusBadRequest, gin.H{
"code": common.CodeBadRequest,
"message": "Invalid request body: " + err.Error(),
})
return
}
@ -973,7 +979,10 @@ func (h *Handler) Reports(c *gin.Context) {
// Only process heartbeat messages for now
if req.MessageType != common.MessageHeartbeat {
errorResponse(c, "Unsupported report type: "+string(req.MessageType), 400)
c.JSON(http.StatusBadRequest, gin.H{
"code": common.CodeBadRequest,
"message": "Unsupported report type: " + string(req.MessageType),
})
return
}

View File

@ -277,8 +277,8 @@ func (s *Service) GetUserPermission(username string) ([]map[string]interface{},
return []map[string]interface{}{}, nil
}
// GetAllServices get all services
func (s *Service) GetAllServices() ([]map[string]interface{}, error) {
// ListServices get all services
func (s *Service) ListServices() ([]map[string]interface{}, error) {
allConfigs := server.GetAllConfigs()
var result []map[string]interface{}

View File

@ -21,13 +21,13 @@ const (
)
type BaseMessage struct {
MessageID int64 `json:"report_id"`
MessageType MessageType `json:"report_type"`
ServerName string `json:"server_id"`
ServerType ServerType `json:"server_type"`
Host string `json:"host"`
Port int `json:"port"`
Version string `json:"version"`
Timestamp time.Time `json:"timestamp"`
Ext map[string]interface{} `json:"ext,omitempty"`
MessageID int64 `json:"report_id"`
MessageType MessageType `json:"report_type"`
ServerName string `json:"server_id"`
ServerType ServerType `json:"server_type"`
Host string `json:"host"`
Port int `json:"port"`
Version string `json:"version"`
Timestamp time.Time `json:"timestamp"`
Ext interface{} `json:"ext,omitempty"`
}

View File

@ -103,7 +103,7 @@ func (h *HeartbeatSender) SendHeartbeat() error {
Port: h.port,
Version: h.version,
Timestamp: time.Now(),
Ext: make(map[string]interface{}),
Ext: nil,
}
jsonData, err := json.Marshal(message)