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
+5 -2
View File
@@ -26,8 +26,11 @@ var (
ErrInvalidFileType = errors.New("unsupported file type")
// ErrInvalidURL is returned when an invalid URL is provided
ErrInvalidURL = errors.New("invalid URL")
// ErrChunkNotFound is returned when a requested chunk cannot be found
ErrChunkNotFound = errors.New("chunk not found")
// ErrChunkNotFound is returned when a requested chunk cannot be found.
// Aliases the repository sentinel so a chunk-not-found from the repo
// errors.Is-matches at the service and middleware layers (a single
// identity instead of two string-equal-but-distinct errors).
ErrChunkNotFound = repository.ErrChunkNotFound
// ErrDuplicateFile is returned when trying to add a file that already exists
ErrDuplicateFile = errors.New("file already exists")
// ErrDuplicateURL is returned when trying to add a URL that already exists