fix(useEntityListProvider): sets arrayLimit to 10000 to solve problem parsing urls with more than 20 occurences of the same query parameter key

Signed-off-by: Jonathan Nagayoshi <jonathan@nagayoshi.com.br>
This commit is contained in:
Jonathan Nagayoshi
2026-01-20 19:59:51 +00:00
parent 4178587bb2
commit f523983563
3 changed files with 28 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-react': patch
---
fixes bug related to qs library upgrade. makes the EntityListProvider return the correct queryParameters even when there are more than 20 occurences of the same value
@@ -222,6 +222,27 @@ describe('<EntityListProvider />', () => {
});
});
it('resolves query param filter values with large arrays', async () => {
const largeArray = Array.from({ length: 50 }, (_, i) => `owner-${i}`);
const query = qs.stringify({
filters: { kind: 'component', owners: largeArray },
});
const { result } = renderHook(() => useEntityList(), {
wrapper: createWrapper({
location: `/catalog?${query}`,
pagination,
}),
});
await waitFor(() => {
expect(result.current.queryParameters).toBeTruthy();
});
expect(result.current.queryParameters).toEqual({
kind: 'component',
owners: largeArray,
});
});
it('does not fetch when only frontend filters change', async () => {
const { result } = renderHook(() => useEntityList(), {
wrapper: createWrapper({ pagination }),
@@ -199,6 +199,7 @@ export const EntityListProvider = <EntityFilters extends DefaultEntityFilters>(
} = useMemo(() => {
const parsed = qs.parse(location.search, {
ignoreQueryPrefix: true,
arrayLimit: 10000,
});
let limit = paginationLimit;
@@ -398,6 +399,7 @@ export const EntityListProvider = <EntityFilters extends DefaultEntityFilters>(
const oldParams = qs.parse(location.search, {
ignoreQueryPrefix: true,
arrayLimit: 10000,
});
const newParams = qs.stringify(
{