diff --git a/internal/handler/chunk.go b/internal/handler/chunk.go index 9e8c20965..262519f25 100644 --- a/internal/handler/chunk.go +++ b/internal/handler/chunk.go @@ -94,7 +94,7 @@ func (h *ChunkHandler) ListKnowledgeChunks(c *gin.Context) { // Parse pagination parameters var pagination types.Pagination if err := c.ShouldBindQuery(&pagination); err != nil { - logger.Error(ctx, "Failed to parse pagination parameters", err) + logger.Errorf(ctx, "Failed to parse pagination parameters: %s", secutils.SanitizeForLog(err.Error())) c.Error(errors.NewBadRequestError(err.Error())) return } @@ -201,7 +201,7 @@ func (h *ChunkHandler) UpdateChunk(c *gin.Context) { } var req UpdateChunkRequest if err := c.ShouldBindJSON(&req); err != nil { - logger.Error(ctx, "Failed to parse request parameters", err) + logger.Errorf(ctx, "Failed to parse request parameters: %s", secutils.SanitizeForLog(err.Error())) c.Error(errors.NewBadRequestError(err.Error())) return } diff --git a/internal/handler/evaluation.go b/internal/handler/evaluation.go index 05b522a0e..9a5ba434d 100644 --- a/internal/handler/evaluation.go +++ b/internal/handler/evaluation.go @@ -94,7 +94,7 @@ func (e *EvaluationHandler) GetEvaluationResult(c *gin.Context) { return } - result, err := e.evaluationService.EvaluationResult(ctx, request.TaskID) + result, err := e.evaluationService.EvaluationResult(ctx, secutils.SanitizeForLog(request.TaskID)) if err != nil { logger.ErrorWithFields(ctx, err, nil) c.Error(errors.NewInternalServerError(err.Error())) diff --git a/internal/handler/session/stream.go b/internal/handler/session/stream.go index 77c4c831d..a14e91c1f 100644 --- a/internal/handler/session/stream.go +++ b/internal/handler/session/stream.go @@ -11,6 +11,7 @@ import ( "github.com/Tencent/WeKnora/internal/logger" "github.com/Tencent/WeKnora/internal/types" "github.com/Tencent/WeKnora/internal/types/interfaces" + secutils "github.com/Tencent/WeKnora/internal/utils" "github.com/gin-gonic/gin" ) @@ -21,7 +22,7 @@ func (h *Handler) ContinueStream(c *gin.Context) { logger.Info(ctx, "Start continuing stream response processing") // Get session ID from URL parameter - sessionID := c.Param("session_id") + sessionID := secutils.SanitizeForLog(c.Param("session_id")) if sessionID == "" { logger.Error(ctx, "Session ID is empty") c.Error(errors.NewBadRequestError(errors.ErrInvalidSessionID.Error())) @@ -29,7 +30,7 @@ func (h *Handler) ContinueStream(c *gin.Context) { } // Get message ID from query parameter - messageID := c.Query("message_id") + messageID := secutils.SanitizeForLog(c.Query("message_id")) if messageID == "" { logger.Error(ctx, "Message ID is empty") c.Error(errors.NewBadRequestError("Missing message ID")) @@ -165,7 +166,7 @@ func (h *Handler) ContinueStream(c *gin.Context) { // StopSession handles the stop generation request func (h *Handler) StopSession(c *gin.Context) { ctx := logger.CloneContext(c.Request.Context()) - sessionID := c.Param("session_id") + sessionID := secutils.SanitizeForLog(c.Param("session_id")) if sessionID == "" { c.JSON(400, gin.H{"error": "Session ID is required"}) @@ -182,7 +183,7 @@ func (h *Handler) StopSession(c *gin.Context) { return } - assistantMessageID := req.MessageID + assistantMessageID := secutils.SanitizeForLog(req.MessageID) logger.Infof(ctx, "Stop generation request for session: %s, message: %s", sessionID, assistantMessageID) // Get tenant ID from context