fix(ingest): reject unknown --kind instead of storing text as a memory - #36
Vaibhavtripathi7 wants to merge 2 commits into
Conversation
|
Signed-off-by: Vaibhavtripathi7 <vaibhavtripathi2020@outlook.com>
8282d26 to
2e1b1e7
Compare
✅ OpenHack SummarySecurity review of fix(ingest): reject unknown --kind instead of storing text as a memory. 3 changed files; 0 findings at or above the low reporting threshold. Confidence Score: 5/5No reportable security findings were detected in this scan. Security merge-readiness rubric: 1 = critical, 2 = high, 3 = medium, 4 = low, 5 = no reportable findings. This score reflects scan findings, not a guarantee of correctness or complete coverage. Files Needing Attention: None Important Files Changed
Last reviewed commit: 98a64a4 · View review on OpenHack
|
What does this PR do?
Makes
hydradb ingestreject an unknown--kindinstead of silently storing the text as a memory.Fixes #35
ingest()insrc/hydradb_cli/commands/canonical.pyonly tested forkind == "knowledge"; every other value fell through todo_ingest_memory, which hard-codeskind="memory". So--kind knowlegdeor--kind Knowledgesenttype=memoryto/context/ingest, printed✓ Memory added, and exited 0. The other commands that take--kind(query,list,delete,relations,subgraph) already reject the same input with--kind must be one of: knowledge, memory;ingestwas the one that didn't.The fix
One guard at the top of
ingest(), before thefilesbranch so a file ingest with a bad--kindis rejected too:It reuses
_impl.VALID_KINDSand the exact error string the other five commands use, so there is still one source of truth for the accepted values.kind=None(flag omitted) still defaults to memory;memoryandknowledgebehave exactly as before. The deprecated aliases (memories add,knowledge upload-text) pass a fixedkindinto_impland are unaffected.Tests
Two tests in
TestIngest:--textwith a bad kind, and a file argument with a bad kind. Each asserts a non-zero exit, the error message, and that the wrapper's ingest method was never called. Both fail onmain(exit code is 0 there) and pass with the fix.Verified
make lintandmake testpass (333 tests)./context/ingest: with the fix,--kind knowlegdeexits 1 in both human and--output jsonmode and no request is sent;--kind knowledgeand the no---kinddefault send the same requests as before.Type of change
Checklist
make lintpasses)make testpasses)git commit -s)