Skip to content

ingest: unknown --kind is silently stored as a memory #35

Description

@Vaibhavtripathi7

CLI Version

hydradb-cli 0.2.0 (installed from source, main at d7f263d)

Python Version

Python 3.14.4

Operating System

EndeavourOS (Arch Linux), kernel 6.18

Bug Description

hydradb ingest does not validate --kind. The only value it checks for is knowledge; anything else falls through to the memory path. So a misspelled or wrongly-cased value (--kind knowlegde, --kind Knowledge) stores the text as a memory, prints ✓ Memory added, and exits 0.

Expected: the same rejection every other command gives. query, list, delete, relations and subgraph all fail with --kind must be one of: knowledge, memory for the same input. The README also documents --kind for ingest as exactly memory (default) or knowledge.

The cause is the branch in src/hydradb_cli/commands/canonical.py, ingest():

if kind == "knowledge":
    _impl.do_ingest_knowledge_text(...)
    return
_impl.do_ingest_memory(...)

Nothing before it checks kind against _impl.VALID_KINDS, and do_ingest_memory hard-codes kind="memory", so the bad value is never seen again.

Steps to Reproduce

  1. Have an API key and a default database configured (hydradb login --database <db>).
  2. Run hydradb ingest --kind knowlegde --text "quarterly notes".
  3. Observe ✓ Memory added, exit code 0. The request sent to /context/ingest carries type=memory and a memories field, so the text is filed as a memory, not knowledge.
  4. Compare: hydradb query "x" --kind knowlegde exits 1 with --kind must be one of: knowledge, memory. Got 'knowlegde'.

CLI Output

$ hydradb ingest --kind knowledge --text "quarterly notes"
  ✓ Knowledge source uploaded to database db
  "quarterly notes"
  Source ID: src_1
$ echo $?
0

$ hydradb ingest --kind knowlegde --text "quarterly notes"
  ✓ Memory added (1 success, 0 failed)
  "quarterly notes"
  Source ID: src_1 (ok)
$ echo $?
0

$ hydradb query "x" --kind knowlegde
  ✗ Error: --kind must be one of: knowledge, memory. Got 'knowlegde'.
$ echo $?
1

(Captured with HYDRADB_BASE_URL pointed at a local stub of the ingest endpoint so the request body could be inspected; the src_1 id is the stub's. The CLI's branching is identical against the real API.)

Additional Context

The deprecated aliases (memories add, knowledge upload-text) are not affected; they pass a fixed kind into _impl directly.

Since this is a silent success rather than an error, a script that builds the --kind value and gets it slightly wrong will keep filing knowledge into the memory corpus with no signal until a later query --kind knowledge comes back empty.

I have a fix ready (one guard in ingest() reusing _impl.VALID_KINDS, plus tests) and will open a PR referencing this issue.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions