Skip to content

Commit 168eb3b

Browse files
authored
fix(query-builder): Send correct payload to value fetching endpoint when key is unknown (#74172)
A small bug was caused because we do not enable `noUncheckedIndexedAccess` in our typescript config. We were keying into `filterKeys` with an unknown key and it returned undefined but the types did not reflect that. (This is an ongoing discussion in the frontend TSC but it's quite a bit of work to enable that config). This was fixed by providing a fallback when sending the key to `getTagValues()`.
1 parent 086f62a commit 168eb3b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

static/app/components/searchQueryBuilder/valueCombobox.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ function useFilterSuggestions({
505505
token: TokenResult<Token.FILTER>;
506506
}) {
507507
const {getTagValues, filterKeys} = useSearchQueryBuilder();
508-
const key = filterKeys[token.key.text];
508+
const key: Tag | undefined = filterKeys[token.key.text];
509509
const predefinedValues = useMemo(
510510
() => getPredefinedValues({key, filterValue, token}),
511511
[key, filterValue, token]
@@ -523,7 +523,8 @@ function useFilterSuggestions({
523523
// TODO(malwilley): Display error states
524524
const {data, isFetching} = useQuery<string[]>({
525525
queryKey: debouncedQueryKey,
526-
queryFn: () => getTagValues(key, filterValue),
526+
queryFn: () =>
527+
getTagValues(key ? key : {key: token.key.text, name: token.key.text}, filterValue),
527528
keepPreviousData: true,
528529
enabled: shouldFetchValues,
529530
});

0 commit comments

Comments
 (0)