The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Answer a transform onto an existing table with 409, not 403 (#83799)
dpsutton63698a3ed8e0
diff --git a/docs/developers-guide/api-changelog.md b/docs/developers-guide/api-changelog.mdindex 32a05da362c..f4b16e0a04d 100644--- a/docs/developers-guide/api-changelog.md+++ b/docs/developers-guide/api-changelog.md@@ -4,6 +4,12 @@ title: API changelog# Breaking changes to the API interface+## Metabase 0.65.0++- `POST /api/transform` and `PUT /api/transform/:id` answer a target table that already exists with+ `409 Conflict` instead of `403 Forbidden`. The message, "A table with that name already exists.", is unchanged.+ `403` remains the answer when the user lacks permission.+## Metabase 0.64.0- `POST /api/slack/bug-report` now requires bug reporting to be enabled (`MB_BUG_REPORTING_ENABLED`).diff --git a/e2e/test/scenarios/data-studio/transforms/transforms.cy.spec.ts b/e2e/test/scenarios/data-studio/transforms/transforms.cy.spec.tsindex 90b7b8cb67c..591782900c6 100644--- a/e2e/test/scenarios/data-studio/transforms/transforms.cy.spec.ts+++ b/e2e/test/scenarios/data-studio/transforms/transforms.cy.spec.ts@@ -1326,7 +1326,7 @@ LIMITcy.button("Change target").click();cy.wait("@updateTransform").its("response.statusCode")- .should("eq", 403);+ .should("eq", 409);cy.findByText("A table with that name already exists.").should("be.visible",);diff --git a/src/metabase/mcp/v2/tools/transform.clj b/src/metabase/mcp/v2/tools/transform.cljindex 94630ecd559..e1345384761 100644--- a/src/metabase/mcp/v2/tools/transform.clj+++ b/src/metabase/mcp/v2/tools/transform.clj@@ -203,7 +203,7 @@(defn- check-target-free!"Refuse a target table that already exists, as the REST create and update check stacks both do.- Restated as a teaching error naming the fix — the REST 403 (\"A table with that name already+ Restated as a teaching error naming the fix — the REST 409 (\"A table with that name alreadyexists.\") says neither which table clashed nor what to do about it."[{:keys [target] :as body}](when (transforms/target-table-exists? body)diff --git a/src/metabase/transforms/crud.clj b/src/metabase/transforms/crud.cljindex 65ccf70876f..a08d1794c44 100644--- a/src/metabase/transforms/crud.clj+++ b/src/metabase/transforms/crud.clj@@ -209,7 +209,7 @@{:status-code 400}))))(api/check (not (and (not= (target-fields old) (target-fields new))(transforms-base.u/target-table-exists? new)))- 403+ 409(deferred-tru "A table with that name already exists.")))(transforms.db/update-transform! id (dissoc body :tag_ids));; Update tag associations if provideddiff --git a/src/metabase/transforms_rest/api/transform.clj b/src/metabase/transforms_rest/api/transform.cljindex 45ebaf4932c..bbc72de77f3 100644--- a/src/metabase/transforms_rest/api/transform.clj+++ b/src/metabase/transforms_rest/api/transform.clj@@ -184,7 +184,7 @@(transforms.core/check-database-feature body)(transforms.core/validate-incremental-column-type! body)(api/check (not (transforms-base.u/target-table-exists? body))- 403+ 409(deferred-tru "A table with that name already exists."))(-> (transforms.core/create-transform! body)transforms.u/add-source-readable))diff --git a/test/metabase/transforms_rest/api/transform_test.clj b/test/metabase/transforms_rest/api/transform_test.cljindex 9ce420c15aa..676c47bf5a4 100644--- a/test/metabase/transforms_rest/api/transform_test.clj+++ b/test/metabase/transforms_rest/api/transform_test.clj@@ -2187,7 +2187,7 @@existing-table-name (t2/select-one-fn :name :model/Table (mt/id :transforms_products))other-existing-name (t2/select-one-fn :name :model/Table (mt/id :transforms_orders))](testing "POST /api/transform"- (mt/user-http-request user :post 403 "transform"+ (mt/user-http-request user :post 409 "transform"{:name "Colliding Transform":source {:type "query" :query (make-query "Gadget")}:target {:type "table"@@ -2201,7 +2201,7 @@:target {:type "table":schema schema:name table-name}})]- (mt/user-http-request user :put 403 (format "transform/%d" (:id created))+ (mt/user-http-request user :put 409 (format "transform/%d" (:id created)){:target {:type "table":schema schema:name other-existing-name}}))))))))))))