Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Guest embedding should use the primary database for queries (#68952)

Sébastien495f4fd39568
diff --git a/.clj-kondo/config/modules/config.edn b/.clj-kondo/config/modules/config.edn
index ec491f5f30f..9750b14846e 100644
--- a/.clj-kondo/config/modules/config.edn
+++ b/.clj-kondo/config/modules/config.edn
@@ -642,6 +642,7 @@
:api #{metabase.embedding-rest.api}
:uses #{api
dashboards
+ database-routing
eid-translation
embedding
events
diff --git a/docs/permissions/database-routing.md b/docs/permissions/database-routing.md
index f99320e0a4d..ca298f1e390 100644
--- a/docs/permissions/database-routing.md
+++ b/docs/permissions/database-routing.md
@@ -13,7 +13,7 @@ Database routing is useful for:
- Managing modular and full app embedding setups where each customer has their own database with identical schemas.
- Database routing can't be used with guest embedding, because database routing requires people who use the embedded questions and dashboards to have a Metabase account. Without a Metabase account, Metabase can't route the queries because it doesn't know who is viewing the embed.
+ With guest embedding, database queries will always be routed to the router database. This is because guest embed users don't have Metabase accounts, so there are no user attributes available to determine which destination database to route to.
- Switching between dev and prod data warehouses.
- Changing the target data warehouse for certain teams.
diff --git a/enterprise/backend/test/metabase_enterprise/database_routing/embedding_test.clj b/enterprise/backend/test/metabase_enterprise/database_routing/embedding_test.clj
new file mode 100644
index 00000000000..b4c87885218
--- /dev/null
+++ b/enterprise/backend/test/metabase_enterprise/database_routing/embedding_test.clj
@@ -0,0 +1,65 @@
+(ns ^:mb/driver-tests metabase-enterprise.database-routing.embedding-test
+ "Tests for database routing with embedding functionality."
+ (:require
+ [buddy.sign.jwt :as jwt]
+ [clojure.test :refer [deftest is testing]]
+ [metabase-enterprise.database-routing.e2e-test :refer [with-temp-dbs! execute-statement!]]
+ [metabase.driver.settings :as driver.settings]
+ [metabase.sync.core :as sync]
+ [metabase.test :as mt]
+ [metabase.test.http-client :as client]
+ [metabase.util :as u]
+ [metabase.util.random :as u.random]
+ [toucan2.core :as t2]))
+
+(defn random-embedding-secret-key [] (u.random/secure-hex 32))
+
+(def ^:dynamic *secret-key* nil)
+
+(defn sign [claims] (jwt/sign claims *secret-key*))
+
+(defn do-with-new-secret-key! [f]
+ (binding [*secret-key* (random-embedding-secret-key)]
+ (mt/with-temporary-setting-values [embedding-secret-key *secret-key*]
+ (f))))
+
+(defmacro with-new-secret-key! {:style/indent 0} [& body]
+ `(do-with-new-secret-key! (fn [] ~@body)))
+
+(defmacro with-embedding-enabled-and-new-secret-key! {:style/indent 0} [& body]
+ `(mt/with-temporary-setting-values [~'enable-embedding-static true
+ ~'enable-embedding-interactive true]
+ (with-new-secret-key!
+ ~@body)))
+
+(defn card-token [card-or-id & [additional-token-keys]]
+ (sign (merge {:resource {:question (u/the-id card-or-id)}
+ :params {}}
+ additional-token-keys)))
+
+(deftest guest-embedding-with-database-routing-test
+ (testing "Guest embedding should work with database routing by bypassing routing"
+ (mt/with-premium-features #{:database-routing}
+ (binding [driver.settings/*allow-testing-h2-connections* true]
+ (with-temp-dbs! [router-db destination-db]
+ ;; Set up router and destination database
+ (t2/update! :model/Database (u/the-id destination-db) {:name "destination-db" :router_database_id (u/the-id router-db)})
+ ;; Sync the router database to ensure tables are available
+ (sync/sync-database! router-db)
+ ;; Set up database routing configuration
+ (mt/with-temp [:model/DatabaseRouter _ {:database_id (u/the-id router-db)
+ :user_attribute "db_name"}
+ :model/Card card {:enable_embedding true
+ :dataset_query {:database (u/the-id router-db)
+ :type :query
+ :query {:source-table (t2/select-one-pk :model/Table :db_id (u/the-id router-db))}}}]
+ ;; Add test data to both databases
+ (execute-statement! router-db "INSERT INTO \"my_database_name\" (str) VALUES ('router-data')")
+ (execute-statement! destination-db "INSERT INTO \"my_database_name\" (str) VALUES ('destination-data')")
+
+ (with-embedding-enabled-and-new-secret-key!
+ (testing "Guest embedding should successfully query the router database"
+ (let [token (card-token card)
+ response (client/client :get 202 (str "embed/card/" token "/query"))]
+ (is (= [["router-data"]] (mt/rows response))
+ "Guest embedding should return data from router database, not destination database"))))))))))
diff --git a/enterprise/frontend/src/metabase-enterprise/database_routing/DatabaseRoutingSection/DatabaseRoutingSection.tsx b/enterprise/frontend/src/metabase-enterprise/database_routing/DatabaseRoutingSection/DatabaseRoutingSection.tsx
index 3f537d863cd..417a231d2fd 100644
--- a/enterprise/frontend/src/metabase-enterprise/database_routing/DatabaseRoutingSection/DatabaseRoutingSection.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/database_routing/DatabaseRoutingSection/DatabaseRoutingSection.tsx
@@ -18,6 +18,7 @@ import { useToast } from "metabase/common/hooks/use-toast";
import { useSelector } from "metabase/lib/redux";
import { getUserIsAdmin } from "metabase/selectors/user";
import {
+ Alert,
Box,
Button,
Flex,
@@ -152,6 +153,16 @@ export const DatabaseRoutingSection = ({
<>
<DatabaseInfoSectionDivider />
+ {hasDbRoutingEnabled(database) && (
+ <Alert
+ variant="light"
+ color="info"
+ icon={<Icon name="info" />}
+ mb="md"
+ >
+ {t`In guest embeds, database queries will always be routed to the router database.`}
+ </Alert>
+ )}
<Stack mb="xl" gap="sm">
<Flex justify="space-between" align="center" gap="sm">
<Box>
diff --git a/frontend/src/metabase/admin/databases/utils.ts b/frontend/src/metabase/admin/databases/utils.ts
index e4368f8f71f..9b91207d5ed 100644
--- a/frontend/src/metabase/admin/databases/utils.ts
+++ b/frontend/src/metabase/admin/databases/utils.ts
@@ -1,4 +1,10 @@
-import type { Database, DatabaseFeature, DatabaseId } from "metabase-types/api";
+import type {
+ Card,
+ Dashboard,
+ Database,
+ DatabaseFeature,
+ DatabaseId,
+} from "metabase-types/api";
export const isDbModifiable = (
database: { id?: DatabaseId; is_attached_dwh?: boolean } | undefined,
@@ -22,3 +28,49 @@ export const hasDbRoutingEnabled = (
) => {
return !!database.router_user_attribute;
};
+
+/**
+ * Check if a question uses a database with routing enabled
+ */
+export const questionUsesRoutingEnabledDatabase = (
+ question: Pick<Card, "database_id">,
+ databases: Pick<Database, "id" | "router_user_attribute">[],
+) => {
+ if (!question.database_id) {
+ return false;
+ }
+
+ const database = databases.find((db) => db.id === question.database_id);
+ return database ? hasDbRoutingEnabled(database) : false;
+};
+
+/**
+ * Check if a dashboard has any questions that use databases with routing enabled
+ */
+export const dashboardUsesRoutingEnabledDatabases = (
+ dashboard: Pick<Dashboard, "dashcards">,
+ databases: Pick<Database, "id" | "router_user_attribute">[],
+) => {
+ if (!dashboard.dashcards) {
+ return false;
+ }
+
+ return dashboard.dashcards.some((dashcard) => {
+ // Check the main card
+ if (
+ dashcard.card &&
+ questionUsesRoutingEnabledDatabase(dashcard.card, databases)
+ ) {
+ return true;
+ }
+
+ // Check series cards (for questions with multiple series) - only available on QuestionDashboardCard
+ if ("series" in dashcard && dashcard.series) {
+ return dashcard.series.some((seriesCard: Card) =>
+ questionUsesRoutingEnabledDatabase(seriesCard, databases),
+ );
+ }
+
+ return false;
+ });
+};
diff --git a/frontend/src/metabase/admin/databases/utils.unit.spec.ts b/frontend/src/metabase/admin/databases/utils.unit.spec.ts
new file mode 100644
index 00000000000..df060337dfc
--- /dev/null
+++ b/frontend/src/metabase/admin/databases/utils.unit.spec.ts
@@ -0,0 +1,95 @@
+import type { Card, Dashboard, Database } from "metabase-types/api";
+
+import {
+ dashboardUsesRoutingEnabledDatabases,
+ hasDbRoutingEnabled,
+ questionUsesRoutingEnabledDatabase,
+} from "./utils";
+
+describe("database routing utility functions", () => {
+ const mockDatabases: Pick<Database, "id" | "router_user_attribute">[] = [
+ { id: 1, router_user_attribute: null },
+ { id: 2, router_user_attribute: "department" },
+ { id: 3, router_user_attribute: "team" },
+ ];
+
+ describe("hasDbRoutingEnabled", () => {
+ it.each([
+ [null, false],
+ [undefined, false],
+ ["department", true],
+ ["team", true],
+ ])(
+ "returns %s when router_user_attribute is %s",
+ (router_user_attribute, expected) => {
+ expect(hasDbRoutingEnabled({ router_user_attribute })).toBe(expected);
+ },
+ );
+ });
+
+ describe("questionUsesRoutingEnabledDatabase", () => {
+ it.each([
+ ["without database_id", { database_id: undefined }, false],
+ ["using database without routing", { database_id: 1 }, false],
+ ["using database with routing", { database_id: 2 }, true],
+ ["using non-existent database", { database_id: 999 }, false],
+ ])("returns %s for question %s", (_, question, expected) => {
+ expect(questionUsesRoutingEnabledDatabase(question, mockDatabases)).toBe(
+ expected,
+ );
+ });
+ });
+
+ describe("dashboardUsesRoutingEnabledDatabases", () => {
+ it.each([
+ ["without dashcards", { dashcards: [] }, false],
+ [
+ "with cards using non-routing databases",
+ {
+ dashcards: [
+ {
+ card: { database_id: 1 } as Card,
+ } as any,
+ ],
+ },
+ false,
+ ],
+ [
+ "with main card using routing-enabled database",
+ {
+ dashcards: [{ card: { database_id: 2 } as Card }],
+ },
+ true,
+ ],
+ [
+ "with series card using routing-enabled database",
+ {
+ dashcards: [
+ {
+ card: { database_id: 1 } as Card,
+ series: [{ database_id: 2 } as Card],
+ } as any,
+ ],
+ },
+ true,
+ ],
+ [
+ "with mixed cards where some use routing",
+ {
+ dashcards: [
+ { card: { database_id: 1 } as Card },
+ { card: { database_id: 2 } as Card },
+ ],
+ },
+ true,
+ ],
+ ])("returns %s for dashboard %s", (_, dashboard, expected) => {
+ expect(
+ dashboardUsesRoutingEnabledDatabases(
+ dashboard as Pick<Dashboard, "dashcards">,
+ mockDatabases,
+ ),
+ ).toBe(expected);
+ });
+ });
+});
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/Authentication/AuthenticationSection.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/Authentication/AuthenticationSection.tsx
index 0cff26f35f8..1cf798f2b4e 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/Authentication/AuthenticationSection.tsx
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/Authentication/AuthenticationSection.tsx
@@ -11,6 +11,10 @@ import { isQuestionOrDashboardExperience } from "metabase/embedding/embedding-if
import { isStepWithResource } from "metabase/embedding/embedding-iframe-sdk-setup/utils/is-step-with-resource";
import { Card, Radio, Stack, Text } from "metabase/ui";
+import { getResourceTypeFromExperience } from "../../utils/get-resource-type-from-experience";
+
+import { DatabaseRoutingWarning } from "./DatabaseRoutingWarning";
+
export const AuthenticationSection = () => {
const {
experience,
@@ -19,9 +23,12 @@ export const AuthenticationSection = () => {
currentStep,
settings,
updateSettings,
+ resource,
} = useSdkIframeEmbedSetupContext();
const handleEmbedExperienceChange = useHandleExperienceChange();
+ const resourceType = getResourceTypeFromExperience(experience);
+
if (!isFirstStep) {
return null;
}
@@ -70,6 +77,13 @@ export const AuthenticationSection = () => {
</Stack>
</Radio.Group>
+ {authType === "guest-embed" && resource && resourceType && (
+ <DatabaseRoutingWarning
+ resource={resource}
+ resourceType={resourceType}
+ />
+ )}
+
<SdkIframeStepEnableEmbeddingSection />
</Stack>
</Card>
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/Authentication/DatabaseRoutingWarning.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/Authentication/DatabaseRoutingWarning.tsx
new file mode 100644
index 00000000000..4804cd902b1
--- /dev/null
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/Authentication/DatabaseRoutingWarning.tsx
@@ -0,0 +1,62 @@
+import { useMemo } from "react";
+import { t } from "ttag";
+
+import {
+ dashboardUsesRoutingEnabledDatabases,
+ questionUsesRoutingEnabledDatabase,
+} from "metabase/admin/databases/utils";
+import { useListDatabasesQuery } from "metabase/api";
+import type {
+ EmbedResource,
+ GuestEmbedResourceType,
+} from "metabase/public/lib/types";
+import { Alert, Icon } from "metabase/ui";
+import type { Card, Dashboard } from "metabase-types/api";
+
+interface DatabaseRoutingWarningProps {
+ resource: EmbedResource;
+ resourceType: GuestEmbedResourceType;
+}
+
+export const DatabaseRoutingWarning = ({
+ resource,
+ resourceType,
+}: DatabaseRoutingWarningProps) => {
+ const { data: databasesResponse } = useListDatabasesQuery();
+
+ // Check if this resource uses databases with routing enabled
+ const usesRoutingEnabledDatabase = useMemo(() => {
+ const databases = databasesResponse?.data || [];
+
+ if (resourceType === "question") {
+ return questionUsesRoutingEnabledDatabase(resource as Card, databases);
+ }
+
+ if (resourceType === "dashboard") {
+ return dashboardUsesRoutingEnabledDatabases(
+ resource as Dashboard,
+ databases,
+ );
+ }
+
+ return false;
+ }, [resource, resourceType, databasesResponse]);
+
+ if (!usesRoutingEnabledDatabase) {
+ return null;
+ }
+
+ return (
+ <Alert
+ variant="light"
+ color="warning"
+ icon={<Icon name="warning" />}
+ title={t`Database routing active`}
+ mb="md"
+ >
+ {resourceType === "dashboard"
+ ? t`One or more questions in this dashboard are querying a database with database routing enabled. The corresponding database queries will be executed against the router database.`
+ : t`This question is querying a database with database routing enabled. The database queries will be executed against the router database.`}
+ </Alert>
+ );
+};
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/Authentication/DatabaseRoutingWarning.unit.spec.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/Authentication/DatabaseRoutingWarning.unit.spec.tsx
new file mode 100644
index 00000000000..cdef0548e60
--- /dev/null
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/Authentication/DatabaseRoutingWarning.unit.spec.tsx
@@ -0,0 +1,172 @@
+import { screen, waitFor } from "@testing-library/react";
+
+import { setupDatabasesEndpoints } from "__support__/server-mocks";
+import { renderWithProviders } from "__support__/ui";
+import { createMockDatabase } from "metabase-types/api/mocks";
+
+import { DatabaseRoutingWarning } from "./DatabaseRoutingWarning";
+
+const setup = (props: {
+ resourceType: "dashboard" | "question";
+ resource: any;
+ databases?: any[];
+}) => {
+ const { resourceType, resource, databases = [] } = props;
+
+ setupDatabasesEndpoints(databases);
+
+ return renderWithProviders(
+ <DatabaseRoutingWarning resource={resource} resourceType={resourceType} />,
+ );
+};
+
+describe("DatabaseRoutingWarning", () => {
+ const mockRoutingDatabase = createMockDatabase({
+ id: 2,
+ router_user_attribute: "department",
+ });
+
+ const mockNormalDatabase = createMockDatabase({
+ id: 1,
+ router_user_attribute: null,
+ });
+
+ describe("for questions", () => {
+ it("does not render warning for question using non-routing database", () => {
+ const question = { database_id: 1 };
+ setup({
+ resourceType: "question",
+ resource: question,
+ databases: [mockNormalDatabase, mockRoutingDatabase],
+ });
+
+ expect(
+ screen.queryByText(
+ /this question is querying a database with database routing enabled/i,
+ ),
+ ).not.toBeInTheDocument();
+ });
+
+ it("renders warning for question using routing-enabled database", async () => {
+ const question = { database_id: 2 };
+ await setup({
+ resourceType: "question",
+ resource: question,
+ databases: [mockNormalDatabase, mockRoutingDatabase],
+ });
+
+ // waitFor because the rendering needs the list of databases and it's async
+ await waitFor(() => {
+ expect(
+ screen.getByText(
+ /this question is querying a database with database routing enabled/i,
+ ),
+ ).toBeInTheDocument();
+ });
+ });
+
+ it("does not render warning for question without database_id", () => {
+ const question = { database_id: undefined };
+ setup({
+ resourceType: "question",
+ resource: question,
+ databases: [mockNormalDatabase, mockRoutingDatabase],
+ });
+
+ expect(
+ screen.queryByText(
+ /this question is querying a database with database routing enabled/i,
+ ),
+ ).not.toBeInTheDocument();
+ });
+ });
+
+ describe("for dashboards", () => {
+ it("does not render warning for dashboard with no routing-enabled databases", () => {
+ const dashboard = {
+ dashcards: [
+ {
+ card: { database_id: 1 },
+ },
+ ],
+ };
+
+ setup({
+ resourceType: "dashboard",
+ resource: dashboard,
+ databases: [mockNormalDatabase, mockRoutingDatabase],
+ });
+
+ expect(
+ screen.queryByText(
+ /one or more questions in this dashboard are querying/i,
+ ),
+ ).not.toBeInTheDocument();
+ });
+
+ it("renders warning for dashboard with routing-enabled databases", async () => {
+ const dashboard = {
+ dashcards: [
+ {
+ card: { database_id: 2 },
+ },
+ ],
+ };
+
+ setup({
+ resourceType: "dashboard",
+ resource: dashboard,
+ databases: [mockNormalDatabase, mockRoutingDatabase],
+ });
+
+ await waitFor(() => {
+ expect(
+ screen.getByText(
+ /one or more questions in this dashboard are querying/i,
+ ),
+ ).toBeInTheDocument();
+ });
+ });
+
+ it("renders warning for dashboard with series cards using routing", async () => {
+ const dashboard = {
+ dashcards: [
+ {
+ card: { database_id: 1 },
+ series: [{ database_id: 2 }],
+ },
+ ],
+ };
+
+ setup({
+ resourceType: "dashboard",
+ resource: dashboard,
+ databases: [mockNormalDatabase, mockRoutingDatabase],
+ });
+
+ await waitFor(() => {
+ expect(
+ screen.getByText(
+ /one or more questions in this dashboard are querying/i,
+ ),
+ ).toBeInTheDocument();
+ });
+ });
+
+ it("does not render warning for dashboard without dashcards", () => {
+ const dashboard = { dashcards: undefined };
+
+ setup({
+ resourceType: "dashboard",
+ resource: dashboard,
+ databases: [mockNormalDatabase, mockRoutingDatabase],
+ });
+
+ expect(
+ screen.queryByText(
+ /one or more questions in this dashboard are querying/i,
+ ),
+ ).not.toBeInTheDocument();
+ });
+ });
+});
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/SdkIframeEmbedSetup.unit.spec.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/SdkIframeEmbedSetup.unit.spec.tsx
index 7285cdb4888..8b9fe30bae7 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/SdkIframeEmbedSetup.unit.spec.tsx
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/SdkIframeEmbedSetup.unit.spec.tsx
@@ -3,6 +3,7 @@ import userEvent from "@testing-library/user-event";
import {
setupCardEndpoints,
setupCardQueryMetadataEndpoint,
+ setupDatabasesEndpoints,
} from "__support__/server-mocks";
import { screen } from "__support__/ui";
import { PLUGIN_EMBEDDING_IFRAME_SDK_SETUP } from "metabase/plugins";
@@ -122,6 +123,7 @@ describe("Embed flow > forward and backward navigation", () => {
const mockDatabase = createMockDatabase();
const mockCard = createMockCard({ id: 456 });
+ setupDatabasesEndpoints([mockDatabase]);
setupCardEndpoints(mockCard);
setupCardQueryMetadataEndpoint(
mockCard,
diff --git a/src/metabase/embedding_rest/api/embed.clj b/src/metabase/embedding_rest/api/embed.clj
index d3aa8960802..87dd2474f00 100644
--- a/src/metabase/embedding_rest/api/embed.clj
+++ b/src/metabase/embedding_rest/api/embed.clj
@@ -17,6 +17,7 @@
(:require
[metabase.api.common :as api]
[metabase.api.macros :as api.macros]
+ [metabase.database-routing.core :as database-routing]
[metabase.eid-translation.core :as eid-translation]
[metabase.embedding-rest.api.common :as api.embed.common]
[metabase.embedding.jwt :as embedding.jwt]
@@ -90,15 +91,16 @@
:as options}]
(let [card-id (embedding.jwt/get-in-unsigned-token-or-throw unsigned-token [:resource :question])]
(api.embed.common/check-embedding-enabled-for-card card-id)
- (api.embed.common/process-query-for-card-with-params
- :export-format export-format
- :card-id card-id
- :token-params (embedding.jwt/get-in-unsigned-token-or-throw unsigned-token [:params])
- :embedding-params (t2/select-one-fn :embedding_params :model/Card :id card-id)
- :query-params (api.embed.common/parse-query-params (dissoc query-params :format_rows :pivot_results))
- :qp qp
- :constraints constraints
- :options options)))
+ (database-routing/with-database-routing-off
+ (api.embed.common/process-query-for-card-with-params
+ :export-format export-format
+ :card-id card-id
+ :token-params (embedding.jwt/get-in-unsigned-token-or-throw unsigned-token [:params])
+ :embedding-params (t2/select-one-fn :embedding_params :model/Card :id card-id)
+ :query-params (api.embed.common/parse-query-params (dissoc query-params :format_rows :pivot_results))
+ :qp qp
+ :constraints constraints
+ :options options))))
;; TODO (Cam 2025-11-25) please add a response schema to this API endpoint, it makes it easier for our customers to
;; use our API + we will need it when we make auto-TypeScript-signature generation happen
@@ -182,17 +184,18 @@
(let [unsigned-token (unsign-and-translate-ids token)
dashboard-id (embedding.jwt/get-in-unsigned-token-or-throw unsigned-token [:resource :dashboard])]
(api.embed.common/check-embedding-enabled-for-dashboard dashboard-id)
- (api.embed.common/process-query-for-dashcard
- :export-format export-format
- :dashboard-id dashboard-id
- :dashcard-id dashcard-id
- :card-id card-id
- :embedding-params (t2/select-one-fn :embedding_params :model/Dashboard :id dashboard-id)
- :token-params (embedding.jwt/get-in-unsigned-token-or-throw unsigned-token [:params])
- :query-params (api.embed.common/parse-query-params (dissoc query-params :format_rows :pivot_results))
- :constraints constraints
- :qp qp
- :middleware middleware)))
+ (database-routing/with-database-routing-off
+ (api.embed.common/process-query-for-dashcard
+ :export-format export-format
+ :dashboard-id dashboard-id
+ :dashcard-id dashcard-id
+ :card-id card-id
+ :embedding-params (t2/select-one-fn :embedding_params :model/Dashboard :id dashboard-id)
+ :token-params (embedding.jwt/get-in-unsigned-token-or-throw unsigned-token [:params])
+ :query-params (api.embed.common/parse-query-params (dissoc query-params :format_rows :pivot_results))
+ :constraints constraints
+ :qp qp
+ :middleware middleware))))
;; TODO (Cam 2025-11-25) please add a response schema to this API endpoint, it makes it easier for our customers to
;; use our API + we will need it when we make auto-TypeScript-signature generation happen