Repository navigation
Fix #737: [Memory] namespaceFromRequest echoes undefined keys, erasing the token-bound use - #738
Memtensor-AI wants to merge 1 commit into
Conversation
namespaceFromRequest echoed every x-memmy-* header as an own property, including absent ones with an undefined value. mergeNamespaces then spread that object over the token-bound principal namespace, so undefined overwrote userId/tenantId and normalizeNamespace fell back to "local-user". Multi-tenant writes were persisted under the wrong user even though reads still used the principal's userId. - namespaceFromRequest now only includes headers that were actually sent - mergeNamespaces drops undefined/null fields before spreading, hardening every caller that passes a partially filled namespace - contract tests cover header-less session open against a cloud token and partial headers alongside an explicit namespace Refs MemTensor#737
π€ Open Code ReviewTarget: PR #738 π OpenCodeReview found 3 issue(s) in this PR. 1.
|
π§ Open Code Review requested Agent fixOpen Code Review found 3 issue(s). I have resumed the development Agent to fix them.
The Agent will push a new commit to this PR branch. OCR will recheck after the commit is pushed. |
Description
Fixed #737: header-absent requests no longer erase a token-bound namespace, so multi-tenant session writes stop landing in "local-user".
Root cause was two-layered: namespaceFromRequest() returned own properties with undefined values for every absent x-memmy-* header, and mergeNamespaces() spread that over the token-bound principal namespace, letting undefined win before normalizeNamespace() fell back to "local-user".
Changes (Memory/src/server/http.ts):
Tests (Memory/tests/contract/memory-rest-service.test.ts):
Both tests fail on the pre-fix code with "local-user" and pass with the fix.
Verification:
npm run typecheck -w @memmy/memorypasses; fullvitest run --dir testsgives 1438 passed / 1 skipped with 2 failures in tests/cli.test.ts that are pre-existing on the baseline (they need a built dist, reproduced with the fix stashed). Contract suite 54/54 and session suite 132/132 pass.Related Issue (Required): Fixes #737
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Automated tests are pending.
Checklist
Reviewer Checklist