Skip to content

Commit e2f98af

Browse files
Fix lakeview publish to explicitly send embed_credentials as false by default (#4066)
Fixes: #4001 ## Changes Add override for `lakeview publish` to explicitly send `embed_credentials: false` when `--embed-credentials` flag is not provided. ## Why The SDK omits `false` boolean values from JSON requests due to `omitempty`. This caused the API to default to `true`, embedding credentials even when the flag wasn't set. The fix uses `ForceSendFields` to always send the value explicitly. ## Tests Added acceptance test verifying the request body contains `"embed_credentials": false`. --------- Co-authored-by: Denis Bilenko <[email protected]>
1 parent b6349a4 commit e2f98af

File tree

7 files changed

+70
-0
lines changed

7 files changed

+70
-0
lines changed

NEXT_CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Notable Changes
66

77
### CLI
8+
* Fix lakeview publish to default `embed_credentials` to false ([#4066](https://github.com/databricks/cli/pull/4066))
89

910
### Bundles
1011
* Add support for configurable catalog/schema for dashboards ([#4130](https://github.com/databricks/cli/pull/4130))
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"method": "POST",
3+
"path": "/api/2.0/workspace/mkdirs",
4+
"body": {
5+
"path": "/Users/[USERNAME]"
6+
}
7+
}
8+
{
9+
"method": "POST",
10+
"path": "/api/2.0/lakeview/dashboards",
11+
"body": {
12+
"display_name": "Test Dashboard",
13+
"parent_path": "/Users/[USERNAME]",
14+
"warehouse_id": "test-warehouse"
15+
}
16+
}
17+
{
18+
"method": "POST",
19+
"path": "/api/2.0/lakeview/dashboards/[DASHBOARD_ID]/published",
20+
"body": {
21+
"embed_credentials": false
22+
}
23+
}

acceptance/workspace/lakeview/publish/out.test.toml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
>>> [CLI] workspace mkdirs /Users/[USERNAME]
3+
4+
>>> [CLI] lakeview create --json {"display_name": "Test Dashboard", "parent_path": "/Users/[USERNAME]", "warehouse_id": "test-warehouse"} -o json
5+
6+
>>> [CLI] lakeview publish [DASHBOARD_ID]
7+
{
8+
"display_name":"Test Dashboard",
9+
"embed_credentials":false,
10+
"warehouse_id":"test-warehouse"
11+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
trace $CLI workspace mkdirs /Users/[email protected]
2+
3+
trace $CLI lakeview create --json '{"display_name": "Test Dashboard", "parent_path": "/Users/[email protected]", "warehouse_id": "test-warehouse"}' -o json > tmp.json
4+
dashboard_id=$(jq -r .dashboard_id < tmp.json)
5+
rm tmp.json
6+
echo "$dashboard_id:DASHBOARD_ID" >> ACC_REPLS
7+
trace $CLI lakeview publish $dashboard_id
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
RecordRequests = true
2+
3+
[Env]
4+
MSYS_NO_PATHCONV = "1"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package lakeview
2+
3+
import (
4+
"github.com/databricks/databricks-sdk-go/service/dashboards"
5+
"github.com/spf13/cobra"
6+
)
7+
8+
func publishOverride(cmd *cobra.Command, req *dashboards.PublishRequest) {
9+
originalRunE := cmd.RunE
10+
cmd.RunE = func(cmd *cobra.Command, args []string) error {
11+
// Force send embed_credentials even when false, otherwise the API defaults to true.
12+
req.ForceSendFields = append(req.ForceSendFields, "EmbedCredentials")
13+
return originalRunE(cmd, args)
14+
}
15+
}
16+
17+
func init() {
18+
publishOverrides = append(publishOverrides, publishOverride)
19+
}

0 commit comments

Comments
 (0)