mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-09 22:10:57 +08:00
security: sanitize internal error messages in API responses
- handler_trader.go: remove loadErr.Error() from 500 responses (2 instances) - handler_ai_cost.go: replace err.Error() with generic message, add logging - Internal errors now logged server-side, not exposed to clients
This commit is contained in:
@@ -495,7 +495,7 @@ func (s *Server) handleStartTrader(c *gin.Context) {
|
||||
logger.Infof("🔄 Loading trader %s from database...", traderID)
|
||||
if loadErr := s.traderManager.LoadUserTradersFromStore(s.store, userID); loadErr != nil {
|
||||
logger.Infof("❌ Failed to load user traders: %v", loadErr)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to load trader: " + loadErr.Error()})
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to load trader configuration"})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -530,7 +530,8 @@ func (s *Server) handleStartTrader(c *gin.Context) {
|
||||
}
|
||||
// Check if there's a specific load error
|
||||
if loadErr := s.traderManager.GetLoadError(traderID); loadErr != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to load trader: " + loadErr.Error()})
|
||||
logger.Infof("❌ Trader %s load error: %v", traderID, loadErr)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to load trader, please check configuration"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "Failed to load trader, please check AI model, exchange and strategy configuration"})
|
||||
|
||||
Reference in New Issue
Block a user