fix: Refine error reporting in agent sync and fix lints.

This commit is contained in:
Haitao Pan 2026-02-06 13:13:44 +08:00
parent 3b818314db
commit 33bd1b8beb

View File

@ -1206,7 +1206,10 @@ func agentListUsersHandler(registry *agentserver.Registry, source xrayconfig.Cli
if logger != nil { if logger != nil {
logger.Error("failed to list clients from source", "err", err, "agent", identity.ID) logger.Error("failed to list clients from source", "err", err, "agent", identity.ID)
} }
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"error": "list_clients_failed", "message": "failed to list clients"}) c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{
"error": "list_clients_failed",
"message": fmt.Sprintf("failed to list clients: %v", err),
})
return return
} }
@ -1272,10 +1275,7 @@ func extractBearerToken(header string) string {
if header == "" { if header == "" {
return "" return ""
} }
const prefix = "Bearer " header = strings.TrimPrefix(header, "Bearer ")
if strings.HasPrefix(header, prefix) {
header = header[len(prefix):]
}
return strings.TrimSpace(header) return strings.TrimSpace(header)
} }