fix(topics): clamp default replication factor to broker count#2420
fix(topics): clamp default replication factor to broker count#2420
Conversation
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.
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.
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.
|
@claude review |
|
Claude finished @c-julin's task in 3m 0s —— View job Code Review
The fix is correct and the approach is sound. Two issues worth addressing before merge, plus some minor notes. Potential bug —
|
Address PR review feedback on #2420. The form-level `resetOptions: { keepDirtyValues: true }` (added so dirty fields survive the late `kafkaInfo` re-init) was leaking into the existing-topic-selected reset, where dirty fields should be overwritten by the selected topic's actual config. Also tighten the RF clamp comment in `create-topic-modal.tsx` to cover the all-brokers-offline case, not just the loading case. Refs UX-1208.
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:
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