diff --git a/packages/server/src/api/controllers/row/views.ts b/packages/server/src/api/controllers/row/views.ts index 220e2098f7..8a1e5e08ce 100644 --- a/packages/server/src/api/controllers/row/views.ts +++ b/packages/server/src/api/controllers/row/views.ts @@ -36,7 +36,7 @@ export async function searchView( // Enrich saved query with ephemeral query params. // We prevent searching on any fields that are saved as part of the query, as // that could let users find rows they should not be allowed to access. - let query: any = dataFilters.buildQuery(view.query ?? []) + let query: any = dataFilters.buildQuery(view.query) if (body.query) { // Delete extraneous search params that cannot be overridden delete body.query.onEmptyFilter diff --git a/packages/shared-core/src/filters.ts b/packages/shared-core/src/filters.ts index 4bb3a6a7df..79c95380e2 100644 --- a/packages/shared-core/src/filters.ts +++ b/packages/shared-core/src/filters.ts @@ -428,7 +428,11 @@ const builderFilter = (expression: SearchFilter) => { return query } -export const buildQuery = (filter: SearchFilterGroup | SearchFilter[]) => { +export const buildQuery = (filter?: SearchFilterGroup | SearchFilter[]) => { + if (!filter) { + return + } + const parsedFilter = processSearchFilters(filter) if (!parsedFilter) {