Skip to content

Pass placement from KeyValueConfig into StreamConfig in create_key_value - #988

Open
corbincallahan wants to merge 1 commit into
nats-io:mainfrom
corbincallahan:create-key-value-placement
Open

corbincallahan wants to merge 1 commit into
nats-io:mainfrom
corbincallahan:create-key-value-placement

Conversation

@corbincallahan

Copy link
Copy Markdown

Fixes #538. Value of placement in given KeyValueConfig was not being used in created StreamConfig. KV placement can now be controlled when using create_key_value.

@caspervonb caspervonb added the nats-legacy Legacy asyncio NATS client label Jul 9, 2026
@caspervonb

caspervonb commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

PTAL @claude

@synadia-claude-reviewer

synadia-claude-reviewer Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Claude finished @caspervonb's task in 39s —— View job


Review: Pass placement from KeyValueConfig into StreamConfig

  • Gather context (PR diff, CLAUDE.md, related code)
  • Review the change for correctness
  • Post review feedback

The change is correct. nats/src/nats/js/client.py:1452 now forwards config.placement into the StreamConfig built in create_key_value. Both KeyValueConfig.placement (nats/src/nats/js/api.py:834) and StreamConfig.placement (nats/src/nats/js/api.py:370) are typed Optional[api.Placement], so this is a direct, type-safe pass-through — consistent with how sibling fields like storage, replicas/num_replicas, and republish are already forwarded a few lines below/above it. This matches the existing pattern used in create_object_store for ObjectStoreConfig.placement as well.

One gap: there's no test covering this. nats/tests/test_js.py has KV tests but none that assert placement set on KeyValueConfig propagates to the resulting stream's StreamConfig.placement. Consider adding a small test that creates a KV bucket with a Placement (e.g. cluster=...) and asserts js.stream_info(...) (or the returned stream config) reflects it — this would also guard against regression if the field ordering/forwarding changes again.

No other issues found — the diff is minimal (1 line), doesn't touch unrelated code, and doesn't require lint/test changes beyond the suggested test.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

nats-legacy Legacy asyncio NATS client

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Placement setting has no effect when creating a new key-value bucket

2 participants