Skip to content

fix(observer): pass RequestContext through vikingdb observer for tenant-scoped vector count#807

Merged
MaojiaSheng merged 1 commit intomainfrom
fix/observer-tenant-scoped-vikingdb-count
Mar 20, 2026
Merged

fix(observer): pass RequestContext through vikingdb observer for tenant-scoped vector count#807
MaojiaSheng merged 1 commit intomainfrom
fix/observer-tenant-scoped-vikingdb-count

Conversation

@qin-ctx
Copy link
Collaborator

@qin-ctx qin-ctx commented Mar 20, 2026

Description

The VikingDB observer and /api/v1/observer/vikingdb endpoint always returned vector_count: 0 for non-default tenants. The root cause is that VikingDBObserver.count() was called without RequestContext, falling back to account_id="default" which filters out vectors belonging to other tenants.

This PR threads RequestContext from the HTTP router all the way through ObserverServiceVikingDBObserverVikingVectorIndexBackend.count(ctx=ctx), so each tenant only sees their own vector count.

Related Issue

Fixes #786

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 not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test update

Changes Made

  • vikingdb_observer.py — Add ctx: Optional[RequestContext] parameter to get_status_table_async(), get_status_table(), and _get_collection_statuses(). Pass ctx to vikingdb_manager.count(ctx=ctx).
  • debug_service.py — Change vikingdb and system from @property to methods accepting ctx parameter. Update is_healthy() to call system().
  • observer.py — Pass ctx from router to ObserverService.vikingdb(ctx=ctx) and ObserverService.system(ctx=ctx) for /vikingdb and /system endpoints.
  • local.py — Adapt get_status() to call system() as a method.
  • tests/ — Update test_debug_service.py and test_vikingdb_observer.py to use method calls instead of property access.
  • docs/ — Update SDK examples in docs/zh/api/07-system.md, docs/en/api/07-system.md, and openviking/storage/observers/README.md to reflect the property-to-method change.

Testing

  • New and existing unit tests pass locally with my changes
  • I have tested this on the following platforms:
    • Linux
    • macOS
    • Windows

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Additional Notes

Breaking change for local SDK users: client.observer.vikingdb and client.observer.system are now methods instead of properties. Users need to add parentheses: client.observer.vikingdb(), client.observer.system(). The HTTP SDK client (_HTTPObserver) is not affected as it has its own independent property-based interface.

This is an alternative approach to PR #802, which used include_all_accounts=True to bypass tenant isolation. That approach has two issues:

  1. It violates multi-tenant isolation by exposing all tenants' vector counts
  2. It has a runtime bug — _SingleAccountBackend.get_collection_info() calls self.count(include_all_accounts=True) but _SingleAccountBackend.count() doesn't accept that parameter, causing a TypeError

Credit-To: jackjin1997

🤖 Generated with Claude Code

…nt-scoped vector count

VikingDBObserver.count() was called without RequestContext, falling back
to account_id="default" and filtering out vectors from other tenants.
Thread ctx from the HTTP router through ObserverService and VikingDBObserver
so each tenant only sees their own vector count.

Closes #786

Credit-To: jackjin1997
@github-actions
Copy link

Failed to generate code suggestions for PR

@MaojiaSheng MaojiaSheng merged commit 7be9514 into main Mar 20, 2026
6 checks passed
@MaojiaSheng MaojiaSheng deleted the fix/observer-tenant-scoped-vikingdb-count branch March 20, 2026 05:47
@github-project-automation github-project-automation bot moved this from Backlog to Done in OpenViking project Mar 20, 2026
zeattacker pushed a commit to zeattacker/OpenViking that referenced this pull request Mar 20, 2026
…nt-scoped vector count (volcengine#807)

VikingDBObserver.count() was called without RequestContext, falling back
to account_id="default" and filtering out vectors from other tenants.
Thread ctx from the HTTP router through ObserverService and VikingDBObserver
so each tenant only sees their own vector count.

Closes volcengine#786

Credit-To: jackjin1997
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug]: Vector Storage Not Persisting to RocksDB - Embedding Succeeds but Vector Count Remains 0

2 participants