Skip to content

Link commands fail with 'KB not found' for newly registered KBs #1

@markramm

Description

@markramm

Bug Description

The kb link and kb links bulk-create commands fail with Error: KB not found for a newly registered and indexed KB, even though kb search, kb get, kb list, and kb tags all work correctly for the same KB.

Steps to Reproduce

  1. Create a new KB directory with kb.yaml and entries
  2. Register it: kb kb add /path/to/kb -n my-kb -t network-investigation -d "description"
  3. Index it: kb kb reindex -k my-kb → succeeds, shows entries added
  4. Verify search works: kb search "test" -k my-kb → succeeds, returns results
  5. Verify get works: kb get entry-id -k my-kb → succeeds
  6. Try to create a link: kb link source-id target-id -k my-kb -r related_tofails with "KB not found"
  7. Try bulk links: kb links bulk-create file.yaml -k my-kbsame error
  8. Also fails: kb kb validate my-kb → "KB not found"
  9. Also fails: kb orient -k my-kb → "KB not found"

Expected Behavior

All commands should find the KB consistently once it's registered and indexed.

Actual Behavior

Search index commands (search, get, tags, list-entries, reindex) work fine.
Link commands, validate, and orient all fail with "KB not found".

This suggests the link subsystem uses a different registry/DB lookup path than the search subsystem.

Environment

  • Pyrite version: latest (as of 2026-04-03)
  • KB type: network-investigation
  • Entries: 106
  • Registration method: kb kb add followed by kb kb reindex

Workaround Attempted

Removed and re-added the KB — same result. The search index is correctly populated but the link/validate/orient subsystems can't find the KB.

Affected Commands

  • kb link
  • kb links bulk-create
  • kb kb validate
  • kb orient
  • kb search
  • kb get
  • kb tags
  • kb list-entries
  • kb kb reindex
  • kb kb list ✅ (shows KB in registry)

Investigation Notes

The main Pyrite DB at ~/.pyrite/pyrite.db appears empty (.tables and .schema return nothing), while the search index is populated. The link system may be looking for entries in the main DB rather than the search index, and the main DB may not have been provisioned for this KB type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions