{{ message }}
Repository navigation
fix: allow documentCount 0 for empty knowledge bases - #19874
Merged
DeJeune merged 3 commits intoSep 3, 2026
Merged
Conversation
Empty knowledge bases persist documentCount=0. The Zod schema used .positive(), so GET /knowledge-bases failed validation and the list never refreshed. Signed-off-by: GokayAI <60583610+gokay-ai@users.noreply.github.com> Co-authored-by: GokayAI <gokay-ai@users.noreply.github.com> Signed-off-by: suyao <sy20010504@gmail.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The change is minimal, aligns validation with persisted data semantics, and includes a focused regression test covering the reported failure case.
Pull request overview
This PR fixes schema validation for knowledge bases by allowing documentCount: 0, which unblocks listing and reloading empty knowledge bases that are valid in storage but previously rejected by Zod parsing.
Changes:
- Relax
KnowledgeDocumentCountSchemafrom “positive integer” to “integer ≥ 0”. - Update existing schema-negative test cases to keep rejecting invalid counts.
- Add an explicit test that
KnowledgeBaseSchemaacceptsdocumentCount: 0.
File summaries
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
eeee0717
approved these changes
Sep 2, 2026
Signed-off-by: suyao <sy20010504@gmail.com>
DeJeune
approved these changes
Sep 2, 2026
Signed-off-by: suyao <sy20010504@gmail.com>
10 of 26 tasks
DeJeune
force-pushed
the
cursor/empty-kb-document-count-bb2e
branch
from
September 3, 2026 10:58
feb43d6 to
c06ed83
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What this PR does
Thanks — this unblocks listing empty knowledge bases.
Before this PR:
Creating an empty knowledge base stored
documentCount=0, butKnowledgeDocumentCountSchemausedz.number().int().positive().GET /knowledge-basesfailed Zod validation, so the list never refreshed and stayed broken after restart.After this PR:
Empty bases with
documentCount: 0pass validation and show up in the list. Negative counts are still rejected.Fixes #19861
Why we need it and why it was done in this way
The following tradeoffs were made:
None. Empty bases are valid; the schema was just too strict.
The following alternatives were considered:
Coercing stored
0toundefinedon read. The list would then succeed, but it would hide a real persisted value. Allowing non-negative counts (.min(0)) matches storage.Links to places where the discussion took place: #19861
Breaking changes
None
Special notes for your reviewer
KnowledgeDocumentCountSchemais shared by create/update and the entity/list schemas..min(0)is the smallest change that lets empty-base list responses parse.Checklist
This checklist is not enforcing, but it's a reminder of items that could be relevant to every PR.
Approvers are expected to review this list.
main/gh-pr-review,gh pr diff, or GitHub UI) before requesting review from othersRelease note