fix(kv): publish KV mutations through the JetStream API prefix for domain contexts - #1011
Open
thejoeejoee wants to merge 2 commits into
Open
fix(kv): publish KV mutations through the JetStream API prefix for domain contexts#1011thejoeejoee wants to merge 2 commits into
thejoeejoee wants to merge 2 commits into
Conversation
thejoeejoee
marked this pull request as ready for review
August 26, 2026 12:32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1010.
Problem
When a
JetStreamContexttargets a JetStream domain (nc.jetstream(domain="leaf")), the API prefix becomes$JS.<domain>.API, butKeyValuemutations (put,create,update,delete,purge) still published to the unqualified local$KV.<bucket>.<key>subject. Over a leafnode this fails withNoStreamResponseError, while reads (bucket lookup,get,watch) already worked through the domain-scoped API.Fix
Match the Go client behavior (
nats.gouseJSPfx): when the context's API prefix is not the default$JS.API, prepend it to the KV data subject for mutations, yielding$JS.<domain>.API.$KV.<bucket>.<key>.Reads (
get,history,keys,watch,purge_deletes) intentionally keep the local$KV.prefix: stream subjects are not prefixed, and watchers filter on the stream's subjects. This mirrors the Go split betweenpre(read) and the JS-prefixed mutation subject.Tests
SingleJetStreamServerDomainTestCase(nats/tests/utils.py) starting a server withjetstream { domain: "test-domain" }(nats/tests/conf/js-domain.conf).KVDomainTest(nats/tests/test_js.py):test_kv_mutations_use_domain_qualified_subject— spies on the connection and asserts every mutation request goes to$JS.test-domain.API.$KV.TEST_DOMAIN.<key>(regression test for the reported bug).test_kv_mutations_work_over_domain— full put/get/create/update/CAS/delete/purge round-trip through a domain-scoped context.test_kv_binding_via_key_value_uses_domain— covers thekey_value()binding path from the issue.All
nats/testspass locally (237 passed, 21 skipped).Out of scope
ObjectStoremutations have the same unqualified-subject issue ($O.<bucket>.C/M.). Left for a follow-up to keep this change minimal.