Skip to content

fix(topics): clamp default replication factor to broker count#2420

Open
c-julin wants to merge 4 commits intomasterfrom
jc/topic-rf-broker-clamp
Open

fix(topics): clamp default replication factor to broker count#2420
c-julin wants to merge 4 commits intomasterfrom
jc/topic-rf-broker-clamp

Conversation

@c-julin
Copy link
Copy Markdown
Contributor

@c-julin c-julin commented Apr 23, 2026

Summary

Three topic-create surfaces in Console hardcoded `replicationFactor: 3`. On single-broker clusters (local-byoc dev environments, degraded prod edges) that caused CreateTopic to fail with "not enough replicas". The RPCN onboarding form was the most visible case because the RF input is rendered `readOnly` — users could see the `3` but had no way to change it.

Files changed:

  • `pages/rp-connect/onboarding/add-topic-step.tsx` — override `TOPIC_FORM_DEFAULTS.replicationFactor` at form init with `min(3, brokersOnline)`. This is the user-visible fix: the readOnly field now shows the correct value for single-broker clusters.
  • `pages/topics/create-topic-modal.tsx` — new topic-create modal; clamp RF inline.
  • `pages/mcp-servers/details/remote-mcp-inspector-tab.tsx` — MCP inspector's inline topic-create flow; clamp RF inline.

All three use `useGetKafkaInfoQuery` to read `brokersOnline` and fall back to the original `3` while the query is loading. On 3+ broker clusters the behavior is unchanged.

Note: the legacy `pages/topics/CreateTopicModal/create-topic-modal.tsx` already reads the default from the broker's `default.replication.factor` config, so it's already correct provided the broker config is correct.

Test plan

  • `bun run test:ci` (unit): 755/755 passed on the branch
  • `bun run lint` auto-sorted imports; no new lint findings introduced by this change
  • Manual verification on a 1-broker local-byoc cluster: RPCN onboarding → Add Topic should show RF=1 (readOnly), CreateTopic succeeds
  • Manual verification on a 3-broker cluster: RPCN onboarding shows RF=3 as before

CreateTopic defaulted replicationFactor to 3 in both the topic-create
modal and the MCP inspector's "create new topic" flow. On single-broker
clusters (local-byoc dev environments, etc.) that rejected the request
with "not enough replicas". Clamp the default to min(3, brokersOnline)
and fall back to 3 while KafkaInfo is loading.
@c-julin
Copy link
Copy Markdown
Contributor Author

c-julin commented Apr 23, 2026

Not needed, closing for now

@c-julin c-julin closed this Apr 23, 2026
The RPCN onboarding Add Topic step spread TOPIC_FORM_DEFAULTS
(replicationFactor: 3) into the form and renders the RF field as
readOnly in AdvancedTopicSettings. On single-broker clusters
(local-byoc dev environments) that meant the user saw RF=3 with no
way to edit, and CreateTopic failed with "not enough replicas".

Override replicationFactor at form init with min(default, brokersOnline)
via useGetKafkaInfoQuery so the readOnly value matches what the broker
can actually satisfy.
@c-julin c-julin reopened this Apr 23, 2026
c-julin added 2 commits April 23, 2026 16:48
Scope back to the user-visible topic-create paths only. The MCP
inspector's "create new topic" flow is out of scope for this PR.
useForm captures defaultValues at mount; when the KafkaInfo query
resolves after mount the RF field stays at its initial 3. Pass
defaultValues through both `defaultValues` and `values` with
`resetOptions: { keepDirtyValues: true }` so the form reactively
picks up the clamped replicationFactor once brokersOnline is known,
without clobbering fields the user has already edited.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant