feat(agents): align update validation errors

This commit is contained in:
2026-06-06 02:41:31 +08:00
parent ec1bb257dc
commit 0ebaa51cbd
4 changed files with 54 additions and 4 deletions
+7
View File
@@ -149,6 +149,13 @@ func (h *AgentHandler) Update(c *gin.Context) {
agent, svcErr := h.svc.Update(c.Request.Context(), uint(id), accountID, req)
if svcErr != nil {
if errors.Is(svcErr, service.ErrAgentNameBlank) {
c.JSON(http.StatusUnprocessableEntity, gin.H{
"message": "Name can't be blank",
"attributes": []string{"name"},
})
return
}
applogger.L().Errorf("Update agent %d for account %d: %v", id, accountID, svcErr)
handleServiceError(c, svcErr)
return