fix(web): harden producer group AutoComplete option filtering - #2872
Open
yyqdbngt wants to merge 1 commit into
Open
fix(web): harden producer group AutoComplete option filtering#2872yyqdbngt wants to merge 1 commit into
yyqdbngt wants to merge 1 commit into
Conversation
RockteMQ-AI
approved these changes
Aug 31, 2026
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
Clean defensive fix — the old ?? false only guarded against a nullish option, not a null/non-string option.value. The new helper correctly coerces both sides with String(...) and covers the edge cases with regression tests.
LGTM.
Automated review by github-manager-bot
RockteMQ-AI
approved these changes
Sep 1, 2026
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
Defensive fix that improves input validation and error handling. Code looks clean and follows existing patterns.
LGTM
Automated review by "github-manager-bot"
RockteMQ-AI
approved these changes
Sep 1, 2026
RockteMQ-AI
left a comment
There was a problem hiding this comment.
LGTM — defensive fix improving input validation and error handling.
Automated review by "github-manager-bot"
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.
Summary
filterOptionin the studio Producer page (pages/studio/Producer.tsx) with an exportedmatchesProducerGroupOptionhelper.option?.value.toLowerCase().includes(inputValue.toLowerCase()) ?? false. The?? falseonly protects the case whereoptionitself is nullish (the optional chain short-circuits); it does NOT protect the cases that actually throw:option.valueisnull/undefined(e.g. anullgroup in the API response) →TypeError: Cannot read properties of null (reading 'toLowerCase')inside the dropdown render;option.value(number, etc.) → sameTypeError.String(...) ?? ''so any option value or search string is compared safely, case-insensitively.Why
The producer-group selector builds its options from live API data (
fetchProducerGroups), unlike the static topic/instance selectors. A single malformed payload entry therefore used to throw inside antd's filter path and break the whole suggestion dropdown. The same defensiveString(option?.label ?? '')pattern is already used incomponents/InstanceSelect.tsx; this brings the Producer selector in line with it.Testing
cd web && ./node_modules/.bin/vitest run src/pages/studio/__tests__/producerGroupFilter.test.ts— 5 new regression tests passed (case-insensitive match, empty input, null/undefined/non-string option values, undefined input).cd web && ./node_modules/.bin/vitest run src/pages/studio/__tests__/Producer.test.tsx— 13 pre-existing tests still pass.cd web && ./node_modules/.bin/tsc --noEmit— clean.cd web && ./node_modules/.bin/eslint src/pages/studio/Producer.tsx src/pages/studio/__tests__/producerGroupFilter.test.ts— 0 errors (1 react-refresh warning for the exported helper, same precedent as other page-level helper exports).