fix(server): case-insensitive doc keyword search + not-found classification

Make document keyword search case-insensitive (LOWER(...) LIKE LOWER(?)) in the
list filter and SearchKnowledge / SearchKnowledgeInScopes paths so a query and
its differently-cased variant return the same results.

Classify not-found consistently as HTTP 404 (not 500) so clients read a
permanent resource.not_found instead of a retryable 5xx: map the document /
chunk not-found sentinels in the KB-access middleware (typed ErrChunkNotFound
via errors.Is), and return 404 for a missing message on the continue-stream and
message-delete endpoints.
This commit is contained in:
nullkey
2026-06-26 20:40:59 +08:00
committed by lyingbug
parent 8f36ea2229
commit 445a4330fa
8 changed files with 77 additions and 20 deletions
+4 -1
View File
@@ -5,6 +5,7 @@ package service
import (
"context"
"errors"
"fmt"
"github.com/Tencent/WeKnora/internal/application/service/retriever"
@@ -107,7 +108,9 @@ func (s *chunkService) GetChunkByID(ctx context.Context, id string) (*types.Chun
func (s *chunkService) GetChunkByIDOnly(ctx context.Context, id string) (*types.Chunk, error) {
chunk, err := s.chunkRepository.GetChunkByIDOnly(ctx, id)
if err != nil {
if err != nil && err.Error() == "chunk not found" {
// errors.Is (not string equality) so the sentinel survives wrapping.
// ErrChunkNotFound aliases the repo sentinel, so this matches directly.
if errors.Is(err, ErrChunkNotFound) {
return nil, ErrChunkNotFound
}
logger.ErrorWithFields(ctx, err, map[string]interface{}{"chunk_id": id})