Skip to content

fix(ingest): reject unknown --kind instead of storing text as a memory - #36

Open
Vaibhavtripathi7 wants to merge 2 commits into
hydra-db:mainfrom
Vaibhavtripathi7:fix/ingest-reject-unknown-kind
Open

Vaibhavtripathi7 wants to merge 2 commits into
hydra-db:mainfrom
Vaibhavtripathi7:fix/ingest-reject-unknown-kind

Conversation

@Vaibhavtripathi7

@Vaibhavtripathi7 Vaibhavtripathi7 commented Sep 11, 2026 •

Copy link
Copy Markdown

What does this PR do?

Makes hydradb ingest reject an unknown --kind instead of silently storing the text as a memory.

Fixes #35

ingest() in src/hydradb_cli/commands/canonical.py only tested for kind == "knowledge"; every other value fell through to do_ingest_memory, which hard-codes kind="memory". So --kind knowlegde or --kind Knowledge sent type=memory to /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; ingest was the one that didn't.

The fix

One guard at the top of ingest(), before the files branch so a file ingest with a bad --kind is rejected too:

if kind and kind not in _impl.VALID_KINDS:
    print_error(f"--kind must be one of: {', '.join(sorted(_impl.VALID_KINDS))}. Got '{kind}'.")

It reuses _impl.VALID_KINDS and 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; memory and knowledge behave exactly as before. The deprecated aliases (memories add, knowledge upload-text) pass a fixed kind into _impl and are unaffected.

Tests

Two tests in TestIngest: --text with 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 on main (exit code is 0 there) and pass with the fix.

Verified

  • make lint and make test pass (333 tests).
  • Ran the installed binary against a local stub of /context/ingest: with the fix, --kind knowlegde exits 1 in both human and --output json mode and no request is sent; --kind knowledge and the no---kind default send the same requests as before.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Chore (CI, tooling, dependencies)

Checklist

  • I have read the CONTRIBUTING guide
  • My code follows the project's style guidelines (make lint passes)
  • I have added tests for my changes (make test passes)
  • All new and existing tests pass
  • My commits are signed off (git commit -s)
  • I have updated documentation if needed

@greptile-apps

greptile-apps Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

The PR appears safe to merge, with the previously reported empty-kind bypass fully fixed and no new actionable issues identified.

Summary

This PR makes hydradb ingest reject unsupported --kind values before either text or file ingestion can run.

  • Uses the shared VALID_KINDS set for validation.
  • Distinguishes an omitted kind from an explicitly empty value.
  • Adds command tests proving invalid values do not invoke the ingestion client.
  • Documents the corrected behavior in the changelog.

Reviews (3) · Last reviewed commit: "Merge branch 'main' into fix/ingest-reje..."

Comment thread src/hydradb_cli/commands/canonical.py Outdated
Signed-off-by: Vaibhavtripathi7 <vaibhavtripathi2020@outlook.com>
@Vaibhavtripathi7
Vaibhavtripathi7 force-pushed the fix/ingest-reject-unknown-kind branch from 8282d26 to 2e1b1e7 Compare September 11, 2026 13:24
@openhack-agent

Copy link
Copy Markdown

✅ OpenHack Summary

Security 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.

P1: Critical 0   P2: High 0   P3: Medium 0   P4: Low 0

Confidence Score: 5/5

No 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
  • CHANGELOG.md (modified)
  • src/hydradb_cli/commands/canonical.py (modified)
  • tests/test_cli_commands.py (modified)

Last reviewed commit: 98a64a4 · View review on OpenHack


TIP: Mention @openhack-agent in a PR comment to request a review or ask a question. Use @openhack-agent fix all for every finding, or @openhack-agent fix unresolved threads for open review threads only.

@openhack-agent openhack-agent Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenHack reviewed this commit. See the OpenHack Summary for the confidence score and fix actions.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant