From 6e8c3a06a2dc9f353e729e938e76af7b810785e5 Mon Sep 17 00:00:00 2001 From: stefanbaxter Date: Tue, 7 Jul 2026 20:20:29 +0000 Subject: [PATCH] fix(query): drop emptyCube.emptyKey order placeholder before sending The query builder emits `emptyCube.emptyKey` as a "no order selected" sentinel in the order state. normalizeOrders passed it straight into the Cube query as `order: {"emptyCube.emptyKey":"asc"}`. The legacy Cube planner silently ignored the unresolvable member; the Tesseract planner rejects it ("Cannot resolve: emptyCube") and 500s the query. Filter the placeholder out in normalizeOrders (both the REST-API and export paths). --- src/components/RestAPI/index.tsx | 14 ++++++++++---- src/hooks/useFormatExport.ts | 14 ++++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/components/RestAPI/index.tsx b/src/components/RestAPI/index.tsx index e16a90f4..7897dfba 100644 --- a/src/components/RestAPI/index.tsx +++ b/src/components/RestAPI/index.tsx @@ -57,10 +57,16 @@ const defaultState = { }; const normalizeOrders = (orders: SortBy[]) => { - return (orders || []).reduce( - (acc, cur) => ({ ...acc, [cur.id]: cur.desc ? "desc" : "asc" }), - {} - ); + // Drop the "no order selected" placeholder the query builder emits + // (`emptyCube.emptyKey`). The legacy Cube planner silently ignored the + // unresolvable member; the Tesseract planner rejects it with + // "Cannot resolve: emptyCube", which 500s the query. + return (orders || []) + .filter((cur) => cur.id && cur.id !== "emptyCube.emptyKey") + .reduce( + (acc, cur) => ({ ...acc, [cur.id]: cur.desc ? "desc" : "asc" }), + {} + ); }; const FORMAT_OPTIONS = [ diff --git a/src/hooks/useFormatExport.ts b/src/hooks/useFormatExport.ts index 96470330..69c0314f 100644 --- a/src/hooks/useFormatExport.ts +++ b/src/hooks/useFormatExport.ts @@ -14,10 +14,16 @@ interface UseFormatExportOptions { } const normalizeOrders = (orders: SortBy[]) => { - return (orders || []).reduce( - (acc, cur) => ({ ...acc, [cur.id]: cur.desc ? "desc" : "asc" }), - {} - ); + // Drop the "no order selected" placeholder the query builder emits + // (`emptyCube.emptyKey`). The legacy Cube planner silently ignored the + // unresolvable member; the Tesseract planner rejects it with + // "Cannot resolve: emptyCube", which 500s the query. + return (orders || []) + .filter((cur) => cur.id && cur.id !== "emptyCube.emptyKey") + .reduce( + (acc, cur) => ({ ...acc, [cur.id]: cur.desc ? "desc" : "asc" }), + {} + ); }; const getFileNameFromDisposition = (header: string | null) => {