Skip to content

fix: Elasticsearch index consistency and tenant-scoped search (#245) - #251

Merged
david87131 merged 2 commits into
vespera-labs:mainfrom
kingbitnation:fix/search-index-consistency-245
Jul 30, 2026
Merged

fix: Elasticsearch index consistency and tenant-scoped search (#245)#251
david87131 merged 2 commits into
vespera-labs:mainfrom
kingbitnation:fix/search-index-consistency-245

Conversation

@kingbitnation

Copy link
Copy Markdown
Contributor

Summary

  • Add transactional search_outbox + Bull search-index relay/reconcile so ES stays aligned with PostgreSQL after property mutations
  • Enforce mandatory server-derived tenant_id + visibility filters on every ES search body (SearchScopeError when scope is missing)
  • Harden the frontend BFF/search hook to drop client tenantId/visibility overrides and derive tenant from the session

Closes #245

Test plan

  • migration:run applies AddSearchOutbox; migration:revert rolls it back
  • Unit: SearchService.query() throws SearchScopeError without tenant and always emits both filters
  • Unit: outbox insert shares the source transaction (rollback undoes the outbox row)
  • Integration: SearchOutboxRelay drains pending rows, retries, dead-letters after SEARCH_OUTBOX_MAX_ATTEMPTS
  • Integration: SearchReconcileJob restores an artificially stale ES document
  • E2E: unlist removes the listing from discovery within one relay cycle; cross-tenant query returns zero foreign docs
  • Frontend typecheck/build with visibility on search result types
  • Backend CI green with Redis + Elasticsearch service containers

@david87131

Copy link
Copy Markdown
Contributor

thanks for your contribution

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.

[Backend] Elasticsearch Index Consistency and Tenant-Scoped Query Authorization for the Search Module

2 participants