Skip to content

fix(cli): name a missing --doc in kb create and kb add instead of dropping it - #3276

Open
XAE-A-Xii wants to merge 1 commit into
HKUDS:devfrom
XAE-A-Xii:fix/kb-cli-missing-doc
Open

XAE-A-Xii wants to merge 1 commit into
HKUDS:devfrom
XAE-A-Xii:fix/kb-cli-missing-doc

Conversation

@XAE-A-Xii

Copy link
Copy Markdown

Description

deeptutor kb create and kb add silently dropped an explicit --doc that doesn't exist, or that is a directory. _collect_documents (deeptutor_cli/kb.py) kept a path only if it was an existing file and skipped anything else without a word. With a typo, the CLI blamed the user for not providing a document:

$ deeptutor kb create zzz-probe --doc /tmp/does-not-exist-typo.md
Provide at least one supported document (--doc or --docs-dir).

Next to a valid --doc, the mistyped file was simply left out, and the KB was built without it.

A missing --doc now raises document does not exist: <path>, and a directory raises document is not a file: <path>. That matches the existing --docs-dir error (docs directory does not exist: ...). Both commands already print typer.BadParameter in red and exit 1:

$ deeptutor kb create zzz-probe --doc /tmp/does-not-exist-typo.md
document does not exist: /private/tmp/does-not-exist-typo.md

Intended behavior change: kb add with one valid and one mistyped --doc now stops instead of quietly adding only the valid file.

Related Issues

  • None filed; this is a small, self-contained fix.

Module(s) Affected

  • agents
  • api
  • config
  • core
  • knowledge
  • logging
  • services
  • tools
  • utils
  • web (Frontend)
  • docs (Documentation)
  • scripts
  • tests
  • Other: deeptutor_cli

Checklist

  • This PR targets dev (not main — see the base-branch selector above).
  • I have read and followed the contribution guidelines.
  • My code follows the project's coding standards.
  • I have run pre-commit run --all-files and fixed any issues.
  • I have added relevant tests for my changes.
  • I have updated the documentation (if necessary). (Not needed.)
  • My changes do not introduce any new security vulnerabilities.

Additional Notes

tests/cli/test_kb_cli.py adds two tests:

  • test_collect_documents_rejects_a_missing_doc_by_name covers a missing --doc alone and next to a valid file, and checks for the does not exist: ...typo.md message.
  • test_collect_documents_rejects_a_directory_passed_as_doc checks for not a file.

With only deeptutor_cli/kb.py reverted, both fail (2 failed, 1 passed). Each branch is guarded separately: removing the existing-check or the is-file check fails one test. (An earlier version matched only the file name, so dropping the "does not exist" branch passed. The assertion now pins the message.)

$ python -m pytest tests/cli/test_kb_cli.py tests/cli/test_kb_eval_cli.py -q
28 passed

pre-commit run --files on both changed files passes every hook. --all-files fails mypy on dev itself in services/embedding/adapters/volcengine.py, from #1015, which this PR doesn't touch. Open PR #2844 also touches deeptutor_cli/kb.py, but only its imports and an eval helper, not _collect_documents.

🤖 Generated with Claude Code

@github-actions github-actions Bot added backend Python runtime, capabilities, tools, API & CLI bug Something isn't working labels Dec 5, 2026
…pping it

`_collect_documents` silently skipped an explicit --doc that did not
exist or was a directory. `deeptutor kb create x --doc typo.md` then
only said "Provide at least one supported document (--doc or
--docs-dir)." although a document was given, and next to a valid
--doc the typo'd file was left out of the KB without a word.

A missing --doc now raises `document does not exist: <path>` and a
directory raises `document is not a file: <path>`, matching the
existing --docs-dir error; both commands already print BadParameter
as a red error and exit 1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@XAE-A-Xii
XAE-A-Xii force-pushed the fix/kb-cli-missing-doc branch from 7ae8130 to 588092b Compare December 5, 2026 12:15

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Python runtime, capabilities, tools, API & CLI bug Something isn't working

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant