fix: always send tenant headers in OpenViking _headers() when account/user are set#21775
fix: always send tenant headers in OpenViking _headers() when account/user are set#21775happy5318 wants to merge 1 commit into
Conversation
…/user are set The _headers() method previously skipped X-OpenViking-Account and X-OpenViking-User headers when their values equaled "default". This caused INVALID_ARGUMENT errors from OpenViking 0.3.x servers when using the ROOT API key, because ROOT-key requests to tenant-scoped APIs require these headers explicitly — even when the account is the literal string "default". User-level keys derive tenancy from the key itself and can omit these headers, but ROOT keys cannot. Remove the != "default" guard so headers are always sent when account/user are non-empty.
|
agree, will fix |
|
this is a bug. While this happens to root api key access. A simple workaround is to use default user apikey. Then these two are not required. |
kshitijk4poor
left a comment
There was a problem hiding this comment.
PR Review — #21775: fix: always send tenant headers in OpenViking _headers() when account/user are set
Verdict: Request Changes
Tests: 18 passed, 2 failed (0 pre-existing — both new regressions)
Changes: 1 file, +8/-7 lines
Critical
-
tests/plugins/memory/test_openviking_provider.py:317–332 —
test_viking_client_headers_omit_tenant_when_legacy_defaultasserts thatX-OpenViking-AccountandX-OpenViking-Userare NOT sent whenaccount="default",user="default". The PR changes this behavior so these headers ARE now sent when account/user are truthy (which"default"is). This test fails and must be updated to assert the headers are present instead. -
tests/plugins/memory/test_openviking_provider.py:335–347 —
test_viking_client_headers_omit_tenant_when_emptypassesaccount=""anduser="", but the constructor translates empty strings to"default"via"" or os.environ.get("OPENVIKING_ACCOUNT", "default"). Soself._accountis actually"default", not empty — and the PR now sends the header. This test also fails and must be updated.
Warnings
- tests/plugins/memory/test_openviking_provider.py:335 — The test name
omit_tenant_when_emptyis misleading. The constructor'sor "default"fallback means passing""results inself._account = "default", so the test was never testing the true-empty case. Consider splitting into: (a) a proper "truly empty" test (monkeypatchOPENVIKING_ACCOUNT=""soself._account = "", assert no headers), and (b) a "default via constructor fallback" test (account unset → defaults to"default"→ headers ARE sent).
Looks Good
- The core fix is correct: removing
!= "default"guard so ROOT API keys can always send tenant headers - The updated docstring in
_headers()is accurate and explains the motivation clearly - Only touches the plugin file (
plugins/memory/openviking/__init__.py) — no core hermes-agent files - The
if self._account:/if self._user:guards still correctly prevent sending empty-string headers - Author is in AUTHOR_MAP ✓
…/user are set OpenViking 0.3.x requires X-OpenViking-Account and X-OpenViking-User headers for ROOT API key requests to tenant-scoped APIs. Previously the `!="default"` guard skipped these headers when account/user were the literal string "default", causing INVALID_ARGUMENT errors. Remove the `!="default"` guard so headers are sent whenever account/user are truthy. Empty strings are still correctly skipped since `""` is falsy. Update tests to reflect the new behavior: - test_viking_client_headers_send_tenant_when_default: asserts "default" headers ARE present - test_viking_client_headers_send_tenant_when_empty_falls_back_to_default: asserts "default" headers ARE present from constructor fallback Based on #21775 by @happy5318
|
Merged via #22414 with test updates — thanks @happy5318! |
…/user are set OpenViking 0.3.x requires X-OpenViking-Account and X-OpenViking-User headers for ROOT API key requests to tenant-scoped APIs. Previously the `!="default"` guard skipped these headers when account/user were the literal string "default", causing INVALID_ARGUMENT errors. Remove the `!="default"` guard so headers are sent whenever account/user are truthy. Empty strings are still correctly skipped since `""` is falsy. Update tests to reflect the new behavior: - test_viking_client_headers_send_tenant_when_default: asserts "default" headers ARE present - test_viking_client_headers_send_tenant_when_empty_falls_back_to_default: asserts "default" headers ARE present from constructor fallback Based on NousResearch#21775 by @happy5318
…/user are set OpenViking 0.3.x requires X-OpenViking-Account and X-OpenViking-User headers for ROOT API key requests to tenant-scoped APIs. Previously the `!="default"` guard skipped these headers when account/user were the literal string "default", causing INVALID_ARGUMENT errors. Remove the `!="default"` guard so headers are sent whenever account/user are truthy. Empty strings are still correctly skipped since `""` is falsy. Update tests to reflect the new behavior: - test_viking_client_headers_send_tenant_when_default: asserts "default" headers ARE present - test_viking_client_headers_send_tenant_when_empty_falls_back_to_default: asserts "default" headers ARE present from constructor fallback Based on NousResearch#21775 by @happy5318
…/user are set OpenViking 0.3.x requires X-OpenViking-Account and X-OpenViking-User headers for ROOT API key requests to tenant-scoped APIs. Previously the `!="default"` guard skipped these headers when account/user were the literal string "default", causing INVALID_ARGUMENT errors. Remove the `!="default"` guard so headers are sent whenever account/user are truthy. Empty strings are still correctly skipped since `""` is falsy. Update tests to reflect the new behavior: - test_viking_client_headers_send_tenant_when_default: asserts "default" headers ARE present - test_viking_client_headers_send_tenant_when_empty_falls_back_to_default: asserts "default" headers ARE present from constructor fallback Based on NousResearch#21775 by @happy5318
…/user are set OpenViking 0.3.x requires X-OpenViking-Account and X-OpenViking-User headers for ROOT API key requests to tenant-scoped APIs. Previously the `!="default"` guard skipped these headers when account/user were the literal string "default", causing INVALID_ARGUMENT errors. Remove the `!="default"` guard so headers are sent whenever account/user are truthy. Empty strings are still correctly skipped since `""` is falsy. Update tests to reflect the new behavior: - test_viking_client_headers_send_tenant_when_default: asserts "default" headers ARE present - test_viking_client_headers_send_tenant_when_empty_falls_back_to_default: asserts "default" headers ARE present from constructor fallback Based on NousResearch#21775 by @happy5318
…/user are set OpenViking 0.3.x requires X-OpenViking-Account and X-OpenViking-User headers for ROOT API key requests to tenant-scoped APIs. Previously the `!="default"` guard skipped these headers when account/user were the literal string "default", causing INVALID_ARGUMENT errors. Remove the `!="default"` guard so headers are sent whenever account/user are truthy. Empty strings are still correctly skipped since `""` is falsy. Update tests to reflect the new behavior: - test_viking_client_headers_send_tenant_when_default: asserts "default" headers ARE present - test_viking_client_headers_send_tenant_when_empty_falls_back_to_default: asserts "default" headers ARE present from constructor fallback Based on NousResearch#21775 by @happy5318
…/user are set OpenViking 0.3.x requires X-OpenViking-Account and X-OpenViking-User headers for ROOT API key requests to tenant-scoped APIs. Previously the `!="default"` guard skipped these headers when account/user were the literal string "default", causing INVALID_ARGUMENT errors. Remove the `!="default"` guard so headers are sent whenever account/user are truthy. Empty strings are still correctly skipped since `""` is falsy. Update tests to reflect the new behavior: - test_viking_client_headers_send_tenant_when_default: asserts "default" headers ARE present - test_viking_client_headers_send_tenant_when_empty_falls_back_to_default: asserts "default" headers ARE present from constructor fallback Based on NousResearch#21775 by @happy5318
…/user are set OpenViking 0.3.x requires X-OpenViking-Account and X-OpenViking-User headers for ROOT API key requests to tenant-scoped APIs. Previously the `!="default"` guard skipped these headers when account/user were the literal string "default", causing INVALID_ARGUMENT errors. Remove the `!="default"` guard so headers are sent whenever account/user are truthy. Empty strings are still correctly skipped since `""` is falsy. Update tests to reflect the new behavior: - test_viking_client_headers_send_tenant_when_default: asserts "default" headers ARE present - test_viking_client_headers_send_tenant_when_empty_falls_back_to_default: asserts "default" headers ARE present from constructor fallback Based on NousResearch#21775 by @happy5318
Problem
The
_headers()method inplugins/memory/openviking/__init__.pyskipsX-OpenViking-AccountandX-OpenViking-Userheaders when their values equal"default":This causes
INVALID_ARGUMENTerrors from OpenViking 0.3.x servers when using the ROOT API key, because ROOT-key requests to tenant-scoped APIs require these headers explicitly — even when the account is the literal string"default".Error message:
Fix
Remove the
!= "default"guard so headers are always sent whenaccount/userare non-empty:User-level keys derive tenancy from the key itself and can omit these headers, but ROOT keys cannot.
Testing
"default"+ user="hermes"