From 8eac7c0330a0738ea057293df88b4a0e574736f7 Mon Sep 17 00:00:00 2001 From: "fabian.jakobs" Date: Tue, 17 Nov 2026 15:25:51 +0000 Subject: [PATCH 1/4] Add thumbnail_path to the apps resource `resources.apps..thumbnail_path` points at a local PNG or JPEG image that `bundle deploy` uploads as the app's thumbnail in the Apps UI. The Apps API can't return the image, so the direct engine keeps only a hash of it in state (hashed_fields): an unchanged file makes no API call, new content uploads only the thumbnail (no app update), and removing the field deletes the thumbnail. The file is checked when the bundle is loaded, so `bundle validate` already rejects files that aren't PNG or JPEG (by signature, like the API) or are larger than 250,000 bytes, the limit of the Apps UI and of the Terraform provider's databricks_app.thumbnail_path. Co-authored-by: Isaac --- .nextchanges/bundles/app-thumbnail.md | 1 + acceptance/bundle/refschema/output/apps.txt | 3 + .../thumbnail-invalid/databricks.yml.tmpl | 9 ++ .../apps/thumbnail-invalid/out.test.toml | 2 + .../apps/thumbnail-invalid/output.txt | 48 +++++++++ .../resources/apps/thumbnail-invalid/script | 9 ++ .../apps/thumbnail-invalid/test.toml | 2 + .../apps/thumbnail-invalid/thumbnail.gif | Bin 0 -> 27 bytes .../thumbnail-upload-fails/databricks.yml | 9 ++ .../apps/thumbnail-upload-fails/out.test.toml | 2 + .../apps/thumbnail-upload-fails/output.txt | 40 +++++++ .../apps/thumbnail-upload-fails/script | 12 +++ .../apps/thumbnail-upload-fails/test.toml | 7 ++ .../apps/thumbnail-upload-fails/thumbnail.png | Bin 0 -> 87 bytes .../resources/apps/thumbnail/app/app.py | 1 + .../bundle/resources/apps/thumbnail/blue.png | Bin 0 -> 87 bytes .../resources/apps/thumbnail/databricks.yml | 9 ++ .../apps/thumbnail/out.requests.json | 37 +++++++ .../resources/apps/thumbnail/out.test.toml | 2 + .../resources/apps/thumbnail/output.txt | 84 +++++++++++++++ .../bundle/resources/apps/thumbnail/red.png | Bin 0 -> 88 bytes .../bundle/resources/apps/thumbnail/script | 44 ++++++++ .../bundle/resources/apps/thumbnail/test.toml | 1 + .../config/mutator/paths/app_paths_visitor.go | 18 +++- .../mutator/paths/app_paths_visitor_test.go | 2 + .../configure_app_thumbnail.go | 82 +++++++++++++++ .../configure_app_thumbnail_test.go | 98 ++++++++++++++++++ .../resourcemutator/resource_mutator.go | 4 + bundle/config/resources/apps.go | 6 ++ bundle/direct/dresources/app.go | 40 ++++++- bundle/direct/dresources/configs/apps.yml | 3 + bundle/direct/dresources/type_test.go | 6 ++ bundle/internal/schema/annotations.yml | 3 + bundle/schema/jsonschema.json | 4 + libs/testserver/apps.go | 27 +++++ libs/testserver/handlers.go | 8 ++ python/databricks/bundles/apps/_models/app.py | 10 ++ 37 files changed, 629 insertions(+), 4 deletions(-) create mode 100644 .nextchanges/bundles/app-thumbnail.md create mode 100644 acceptance/bundle/resources/apps/thumbnail-invalid/databricks.yml.tmpl create mode 100644 acceptance/bundle/resources/apps/thumbnail-invalid/out.test.toml create mode 100644 acceptance/bundle/resources/apps/thumbnail-invalid/output.txt create mode 100644 acceptance/bundle/resources/apps/thumbnail-invalid/script create mode 100644 acceptance/bundle/resources/apps/thumbnail-invalid/test.toml create mode 100644 acceptance/bundle/resources/apps/thumbnail-invalid/thumbnail.gif create mode 100644 acceptance/bundle/resources/apps/thumbnail-upload-fails/databricks.yml create mode 100644 acceptance/bundle/resources/apps/thumbnail-upload-fails/out.test.toml create mode 100644 acceptance/bundle/resources/apps/thumbnail-upload-fails/output.txt create mode 100644 acceptance/bundle/resources/apps/thumbnail-upload-fails/script create mode 100644 acceptance/bundle/resources/apps/thumbnail-upload-fails/test.toml create mode 100644 acceptance/bundle/resources/apps/thumbnail-upload-fails/thumbnail.png create mode 100644 acceptance/bundle/resources/apps/thumbnail/app/app.py create mode 100644 acceptance/bundle/resources/apps/thumbnail/blue.png create mode 100644 acceptance/bundle/resources/apps/thumbnail/databricks.yml create mode 100644 acceptance/bundle/resources/apps/thumbnail/out.requests.json create mode 100644 acceptance/bundle/resources/apps/thumbnail/out.test.toml create mode 100644 acceptance/bundle/resources/apps/thumbnail/output.txt create mode 100644 acceptance/bundle/resources/apps/thumbnail/red.png create mode 100644 acceptance/bundle/resources/apps/thumbnail/script create mode 100644 acceptance/bundle/resources/apps/thumbnail/test.toml create mode 100644 bundle/config/mutator/resourcemutator/configure_app_thumbnail.go create mode 100644 bundle/config/mutator/resourcemutator/configure_app_thumbnail_test.go diff --git a/.nextchanges/bundles/app-thumbnail.md b/.nextchanges/bundles/app-thumbnail.md new file mode 100644 index 00000000000..a58fdca22a1 --- /dev/null +++ b/.nextchanges/bundles/app-thumbnail.md @@ -0,0 +1 @@ +* Add `thumbnail_path` to the `apps` resource, so `bundle deploy` sets, updates and deletes the thumbnail shown for the app in the Apps UI. ([#7728](https://github.com/databricks/cli/pull/7728)) diff --git a/acceptance/bundle/refschema/output/apps.txt b/acceptance/bundle/refschema/output/apps.txt index 9ab8ebb19aa..cf74fb702eb 100644 --- a/acceptance/bundle/refschema/output/apps.txt +++ b/acceptance/bundle/refschema/output/apps.txt @@ -230,6 +230,9 @@ resources.apps.*.telemetry_export_destinations[*].unity_catalog *apps.UnityCatal resources.apps.*.telemetry_export_destinations[*].unity_catalog.logs_table string ALL resources.apps.*.telemetry_export_destinations[*].unity_catalog.metrics_table string ALL resources.apps.*.telemetry_export_destinations[*].unity_catalog.traces_table string ALL +resources.apps.*.thumbnail string STATE +resources.apps.*.thumbnail_content string INPUT +resources.apps.*.thumbnail_path string INPUT resources.apps.*.thumbnail_url string ALL resources.apps.*.update_time string ALL resources.apps.*.updater string ALL diff --git a/acceptance/bundle/resources/apps/thumbnail-invalid/databricks.yml.tmpl b/acceptance/bundle/resources/apps/thumbnail-invalid/databricks.yml.tmpl new file mode 100644 index 00000000000..6094f957d5d --- /dev/null +++ b/acceptance/bundle/resources/apps/thumbnail-invalid/databricks.yml.tmpl @@ -0,0 +1,9 @@ +bundle: + name: test-bundle + +resources: + apps: + myapp: + name: myappname + source_code_path: . + thumbnail_path: $THUMBNAIL_PATH diff --git a/acceptance/bundle/resources/apps/thumbnail-invalid/out.test.toml b/acceptance/bundle/resources/apps/thumbnail-invalid/out.test.toml new file mode 100644 index 00000000000..a927a5fbc06 --- /dev/null +++ b/acceptance/bundle/resources/apps/thumbnail-invalid/out.test.toml @@ -0,0 +1,2 @@ +Cloud = false +EnvMatrix.DMS = ["", "true"] diff --git a/acceptance/bundle/resources/apps/thumbnail-invalid/output.txt b/acceptance/bundle/resources/apps/thumbnail-invalid/output.txt new file mode 100644 index 00000000000..fa404edfc95 --- /dev/null +++ b/acceptance/bundle/resources/apps/thumbnail-invalid/output.txt @@ -0,0 +1,48 @@ + +=== thumbnail_path: ./thumbnail.gif + +>>> [CLI] bundle validate +Error: app thumbnail thumbnail.gif must be a PNG or JPEG image, got image/gif + in databricks.yml:9:23 + +Name: test-bundle +Target: default +Workspace: + User: [USERNAME] + Path: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default + +Found 1 error + +Exit code: 1 + +=== thumbnail_path: ./large.png + +>>> [CLI] bundle validate +Error: app thumbnail large.png is 250001 bytes, larger than the limit of 250000 bytes + in databricks.yml:9:23 + +Name: test-bundle +Target: default +Workspace: + User: [USERNAME] + Path: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default + +Found 1 error + +Exit code: 1 + +=== thumbnail_path: ./missing.png + +>>> [CLI] bundle validate +Error: failed to read app thumbnail missing.png: open missing.png: no such file or directory + in databricks.yml:9:23 + +Name: test-bundle +Target: default +Workspace: + User: [USERNAME] + Path: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default + +Found 1 error + +Exit code: 1 diff --git a/acceptance/bundle/resources/apps/thumbnail-invalid/script b/acceptance/bundle/resources/apps/thumbnail-invalid/script new file mode 100644 index 00000000000..5be01607bc8 --- /dev/null +++ b/acceptance/bundle/resources/apps/thumbnail-invalid/script @@ -0,0 +1,9 @@ +# One byte over the 250,000-byte limit, with a PNG signature. +python3 -c "import sys; sys.stdout.buffer.write(b'\x89PNG\r\n\x1a\n' + bytes(250_001 - 8))" > large.png + +for THUMBNAIL_PATH in ./thumbnail.gif ./large.png ./missing.png; do + title "thumbnail_path: $THUMBNAIL_PATH" + export THUMBNAIL_PATH + envsubst < databricks.yml.tmpl > databricks.yml + errcode trace $CLI bundle validate +done diff --git a/acceptance/bundle/resources/apps/thumbnail-invalid/test.toml b/acceptance/bundle/resources/apps/thumbnail-invalid/test.toml new file mode 100644 index 00000000000..1beb9c803b8 --- /dev/null +++ b/acceptance/bundle/resources/apps/thumbnail-invalid/test.toml @@ -0,0 +1,2 @@ +RecordRequests = false +Ignore = ["large.png"] diff --git a/acceptance/bundle/resources/apps/thumbnail-invalid/thumbnail.gif b/acceptance/bundle/resources/apps/thumbnail-invalid/thumbnail.gif new file mode 100644 index 0000000000000000000000000000000000000000..c98b9a76c6f2c15f6f531405bf0e6a3f2897abcb GIT binary patch literal 27 QcmZ?wbhEHbWWWNr04SFMvj6}9 literal 0 HcmV?d00001 diff --git a/acceptance/bundle/resources/apps/thumbnail-upload-fails/databricks.yml b/acceptance/bundle/resources/apps/thumbnail-upload-fails/databricks.yml new file mode 100644 index 00000000000..946d3f18574 --- /dev/null +++ b/acceptance/bundle/resources/apps/thumbnail-upload-fails/databricks.yml @@ -0,0 +1,9 @@ +bundle: + name: test-bundle + +resources: + apps: + mykey: + name: myappname + source_code_path: . + thumbnail_path: ./thumbnail.png diff --git a/acceptance/bundle/resources/apps/thumbnail-upload-fails/out.test.toml b/acceptance/bundle/resources/apps/thumbnail-upload-fails/out.test.toml new file mode 100644 index 00000000000..a927a5fbc06 --- /dev/null +++ b/acceptance/bundle/resources/apps/thumbnail-upload-fails/out.test.toml @@ -0,0 +1,2 @@ +Cloud = false +EnvMatrix.DMS = ["", "true"] diff --git a/acceptance/bundle/resources/apps/thumbnail-upload-fails/output.txt b/acceptance/bundle/resources/apps/thumbnail-upload-fails/output.txt new file mode 100644 index 00000000000..e51eff6218a --- /dev/null +++ b/acceptance/bundle/resources/apps/thumbnail-upload-fails/output.txt @@ -0,0 +1,40 @@ + +=== A failed upload after create keeps the app in state and leaves the thumbnail out of it + +>>> [CLI] bundle deploy +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... +Warning: failed to upload the thumbnail of app myappname, the next deploy retries it: Unsupported image +Created apps.mykey +Files: 2 uploaded, 0 deleted +Resources: 1 created, 0 changed, 0 deleted, 0 unchanged + +>>> jq .state["resources.apps.mykey"].state.thumbnail .databricks/bundle/default/resources.json +null + +=== The next deploy retries the upload + +>>> [CLI] bundle plan +update apps.mykey + +Plan: 0 to add, 1 to change, 0 to delete, 0 unchanged + +>>> [CLI] bundle deploy +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... +Error: cannot update resources.apps.mykey: updating id=myappname: Unsupported image (400 INVALID_PARAMETER_VALUE) + +Endpoint: PATCH [DATABRICKS_URL]/api/2.0/apps/myappname/thumbnail +HTTP Status: 400 Bad Request +API error_code: INVALID_PARAMETER_VALUE +API message: Unsupported image + +Files: 0 uploaded, 0 deleted + +Exit code: 1 + +>>> [CLI] bundle destroy --auto-approve +The following resources will be deleted: + delete resources.apps.mykey + +All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default + +Destroy: 1 deleted diff --git a/acceptance/bundle/resources/apps/thumbnail-upload-fails/script b/acceptance/bundle/resources/apps/thumbnail-upload-fails/script new file mode 100644 index 00000000000..a7b045773e3 --- /dev/null +++ b/acceptance/bundle/resources/apps/thumbnail-upload-fails/script @@ -0,0 +1,12 @@ +cleanup() { + trace $CLI bundle destroy --auto-approve +} +trap cleanup EXIT + +title "A failed upload after create keeps the app in state and leaves the thumbnail out of it" +trace $CLI bundle deploy +trace jq '.state["resources.apps.mykey"].state.thumbnail' .databricks/bundle/default/resources.json + +title "The next deploy retries the upload" +trace $CLI bundle plan +errcode trace $CLI bundle deploy diff --git a/acceptance/bundle/resources/apps/thumbnail-upload-fails/test.toml b/acceptance/bundle/resources/apps/thumbnail-upload-fails/test.toml new file mode 100644 index 00000000000..07e5fff4dcc --- /dev/null +++ b/acceptance/bundle/resources/apps/thumbnail-upload-fails/test.toml @@ -0,0 +1,7 @@ +RecordRequests = false +Ignore = [".databricks"] + +[[Server]] +Pattern = "PATCH /api/2.0/apps/{name}/thumbnail" +Response.StatusCode = 400 +Response.Body = '''{"error_code": "INVALID_PARAMETER_VALUE", "message": "Unsupported image"}''' diff --git a/acceptance/bundle/resources/apps/thumbnail-upload-fails/thumbnail.png b/acceptance/bundle/resources/apps/thumbnail-upload-fails/thumbnail.png new file mode 100644 index 0000000000000000000000000000000000000000..221d032519971d60bf2162070c759f5ed7966aa9 GIT binary patch literal 87 zcmeAS@N?(olHy`uVBq!ia0vp^3P3Ex!2~3?uJUFDQgWUyjv*Ddk`oes_$QlW9bCb> jSga??0K_QSz`$@m!1n$c--j=ODj7Uo{an^LB{Ts5ZeSSi literal 0 HcmV?d00001 diff --git a/acceptance/bundle/resources/apps/thumbnail/app/app.py b/acceptance/bundle/resources/apps/thumbnail/app/app.py new file mode 100644 index 00000000000..f1a18139c84 --- /dev/null +++ b/acceptance/bundle/resources/apps/thumbnail/app/app.py @@ -0,0 +1 @@ +print("Hello world!") diff --git a/acceptance/bundle/resources/apps/thumbnail/blue.png b/acceptance/bundle/resources/apps/thumbnail/blue.png new file mode 100644 index 0000000000000000000000000000000000000000..221d032519971d60bf2162070c759f5ed7966aa9 GIT binary patch literal 87 zcmeAS@N?(olHy`uVBq!ia0vp^3P3Ex!2~3?uJUFDQgWUyjv*Ddk`oes_$QlW9bCb> jSga??0K_QSz`$@m!1n$c--j=ODj7Uo{an^LB{Ts5ZeSSi literal 0 HcmV?d00001 diff --git a/acceptance/bundle/resources/apps/thumbnail/databricks.yml b/acceptance/bundle/resources/apps/thumbnail/databricks.yml new file mode 100644 index 00000000000..6e4dccc4aaf --- /dev/null +++ b/acceptance/bundle/resources/apps/thumbnail/databricks.yml @@ -0,0 +1,9 @@ +bundle: + name: test-bundle + +resources: + apps: + mykey: + name: myappname + source_code_path: ./app + thumbnail_path: ./thumbnail.png diff --git a/acceptance/bundle/resources/apps/thumbnail/out.requests.json b/acceptance/bundle/resources/apps/thumbnail/out.requests.json new file mode 100644 index 00000000000..dee2b2323b4 --- /dev/null +++ b/acceptance/bundle/resources/apps/thumbnail/out.requests.json @@ -0,0 +1,37 @@ +{ + "method": "POST", + "path": "/api/2.0/apps", + "q": { + "no_compute": "true" + }, + "body": { + "description": "", + "name": "myappname" + } +} +{ + "method": "PATCH", + "path": "/api/2.0/apps/myappname/thumbnail", + "body": { + "app_thumbnail": { + "thumbnail": "iVBORw0KGgoAAAANSUhEUgAAACAAAAASCAIAAAC1qksFAAAAHklEQVR42mNgYPhPYzRqwagFoxaMWjBqwagFdLAAAM9QPd+sTeHpAAAAAElFTkSuQmCC" + } + } +} +{ + "method": "PATCH", + "path": "/api/2.0/apps/myappname/thumbnail", + "body": { + "app_thumbnail": { + "thumbnail": "iVBORw0KGgoAAAANSUhEUgAAACAAAAASCAIAAAC1qksFAAAAH0lEQVR42mP4z8BAU8QwasGoBaMWjFowasGoBfSwAABLGz3fTe+jHwAAAABJRU5ErkJggg==" + } + } +} +{ + "method": "DELETE", + "path": "/api/2.0/apps/myappname/thumbnail" +} +{ + "method": "DELETE", + "path": "/api/2.0/apps/myappname" +} diff --git a/acceptance/bundle/resources/apps/thumbnail/out.test.toml b/acceptance/bundle/resources/apps/thumbnail/out.test.toml new file mode 100644 index 00000000000..a927a5fbc06 --- /dev/null +++ b/acceptance/bundle/resources/apps/thumbnail/out.test.toml @@ -0,0 +1,2 @@ +Cloud = false +EnvMatrix.DMS = ["", "true"] diff --git a/acceptance/bundle/resources/apps/thumbnail/output.txt b/acceptance/bundle/resources/apps/thumbnail/output.txt new file mode 100644 index 00000000000..f919b65231a --- /dev/null +++ b/acceptance/bundle/resources/apps/thumbnail/output.txt @@ -0,0 +1,84 @@ + +=== Deploy with a thumbnail: the image is uploaded after the app is created + +>>> [CLI] bundle deploy +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... +Created apps.mykey +Files: 5 uploaded, 0 deleted +Resources: 1 created, 0 changed, 0 deleted, 0 unchanged + +>>> print_requests + +>>> [CLI] apps get myappname +"/ajax-api/2.0/thumbnails/raw/apps/1000/SMALL_DEFAULT.png" + +=== State keeps only a hash of the image + +>>> jq .state["resources.apps.mykey"].state.thumbnail .databricks/bundle/default/resources.json +"sha256:[HASH]" + +=== Redeploy with an unchanged image: no thumbnail request + +>>> [CLI] bundle plan +Plan: 0 to add, 0 to change, 0 to delete, 1 unchanged + +>>> [CLI] bundle deploy +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... +Files: 1 uploaded, 0 deleted +Resources: 0 created, 0 changed, 0 deleted, 1 unchanged + +>>> print_requests + +=== New content at the same path: only the thumbnail is uploaded + +>>> [CLI] bundle plan +update apps.mykey + +Plan: 0 to add, 1 to change, 0 to delete, 0 unchanged + +>>> [CLI] bundle deploy +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... +Updated apps.mykey +Files: 1 uploaded, 0 deleted +Resources: 0 created, 1 changed, 0 deleted, 0 unchanged + +>>> print_requests + +=== Deploy from a saved plan: the plan carries the image, not its hash + +>>> [CLI] bundle deploy --plan tmp.plan.json +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... +Updated apps.mykey +Files: 3 uploaded, 0 deleted +Resources: 0 created, 1 changed, 0 deleted, 0 unchanged + +>>> print_requests.py //apps ^//api/2.0/bundle +iVBORw0KGgoA + +=== Remove thumbnail_path: the thumbnail is deleted + +>>> [CLI] bundle plan +update apps.mykey + +Plan: 0 to add, 1 to change, 0 to delete, 0 unchanged + +>>> [CLI] bundle deploy +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... +Updated apps.mykey +Files: 1 uploaded, 0 deleted +Resources: 0 created, 1 changed, 0 deleted, 0 unchanged + +>>> print_requests + +>>> [CLI] apps get myappname +null + +>>> [CLI] bundle destroy --auto-approve +The following resources will be deleted: + delete resources.apps.mykey + +All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default + +Destroy: 1 deleted + +>>> print_requests diff --git a/acceptance/bundle/resources/apps/thumbnail/red.png b/acceptance/bundle/resources/apps/thumbnail/red.png new file mode 100644 index 0000000000000000000000000000000000000000..d7a119ce4bf6af7fed3fcbb6e7e13e6405b60f93 GIT binary patch literal 88 zcmeAS@N?(olHy`uVBq!ia0vp^3P3Ex!2~3?uJUFDQu3ZIjv*Ddl7E~(;1GPoAnV`? j*2Q8yQDDZG4Gaw4(zf?~-!GO2DrN9=^>bP0l+XkKs8<> out.requests.json +} +trap cleanup EXIT + +cp blue.png thumbnail.png + +title "Deploy with a thumbnail: the image is uploaded after the app is created" +trace $CLI bundle deploy +trace print_requests > out.requests.json +trace $CLI apps get myappname | jq .thumbnail_url + +title "State keeps only a hash of the image" +trace jq '.state["resources.apps.mykey"].state.thumbnail' .databricks/bundle/default/resources.json + +title "Redeploy with an unchanged image: no thumbnail request" +trace $CLI bundle plan +trace $CLI bundle deploy +trace print_requests >> out.requests.json + +title "New content at the same path: only the thumbnail is uploaded" +cp red.png thumbnail.png +trace $CLI bundle plan +trace $CLI bundle deploy +trace print_requests >> out.requests.json + +title "Deploy from a saved plan: the plan carries the image, not its hash" +cp blue.png thumbnail.png +$CLI bundle plan -o json > tmp.plan.json +trace $CLI bundle deploy --plan tmp.plan.json +trace print_requests.py //apps '^//api/2.0/bundle' | jq -r '.body.app_thumbnail.thumbnail | .[0:12]' + +title "Remove thumbnail_path: the thumbnail is deleted" +grep -v thumbnail_path databricks.yml > databricks.yml.new +mv databricks.yml.new databricks.yml +trace $CLI bundle plan +trace $CLI bundle deploy +trace print_requests >> out.requests.json +trace $CLI apps get myappname | jq .thumbnail_url diff --git a/acceptance/bundle/resources/apps/thumbnail/test.toml b/acceptance/bundle/resources/apps/thumbnail/test.toml new file mode 100644 index 00000000000..ac9587743bc --- /dev/null +++ b/acceptance/bundle/resources/apps/thumbnail/test.toml @@ -0,0 +1 @@ +Ignore = [".databricks", "thumbnail.png", "databricks.yml.new", "tmp.plan.json"] diff --git a/bundle/config/mutator/paths/app_paths_visitor.go b/bundle/config/mutator/paths/app_paths_visitor.go index 21a7e467ae2..d604af0e721 100644 --- a/bundle/config/mutator/paths/app_paths_visitor.go +++ b/bundle/config/mutator/paths/app_paths_visitor.go @@ -5,14 +5,28 @@ import ( ) func VisitAppPaths(value dyn.Value, fn VisitFunc) (dyn.Value, error) { - pattern := dyn.NewPattern( + sourceCodePattern := dyn.NewPattern( dyn.Key("resources"), dyn.Key("apps"), dyn.AnyKey(), dyn.Key("source_code_path"), ) - return dyn.MapByPattern(value, pattern, func(path dyn.Path, value dyn.Value) (dyn.Value, error) { + value, err := dyn.MapByPattern(value, sourceCodePattern, func(path dyn.Path, value dyn.Value) (dyn.Value, error) { return fn(path, TranslateModeDirectory, value) }) + if err != nil { + return dyn.InvalidValue, err + } + + thumbnailPattern := dyn.NewPattern( + dyn.Key("resources"), + dyn.Key("apps"), + dyn.AnyKey(), + dyn.Key("thumbnail_path"), + ) + + return dyn.MapByPattern(value, thumbnailPattern, func(path dyn.Path, value dyn.Value) (dyn.Value, error) { + return fn(path, TranslateModeLocalRelative, value) + }) } diff --git a/bundle/config/mutator/paths/app_paths_visitor_test.go b/bundle/config/mutator/paths/app_paths_visitor_test.go index 9ec01aeaf83..a66180fb59a 100644 --- a/bundle/config/mutator/paths/app_paths_visitor_test.go +++ b/bundle/config/mutator/paths/app_paths_visitor_test.go @@ -18,6 +18,7 @@ func TestAppPathsVisitor(t *testing.T) { App: apps.App{ SourceCodePath: "foo", }, + ThumbnailPath: "thumbnail.png", }, }, }, @@ -26,6 +27,7 @@ func TestAppPathsVisitor(t *testing.T) { actual := collectVisitedPaths(t, root, VisitAppPaths) expected := []dyn.Path{ dyn.MustPathFromString("resources.apps.app0.source_code_path"), + dyn.MustPathFromString("resources.apps.app0.thumbnail_path"), } assert.ElementsMatch(t, expected, actual) diff --git a/bundle/config/mutator/resourcemutator/configure_app_thumbnail.go b/bundle/config/mutator/resourcemutator/configure_app_thumbnail.go new file mode 100644 index 00000000000..9a2040c860c --- /dev/null +++ b/bundle/config/mutator/resourcemutator/configure_app_thumbnail.go @@ -0,0 +1,82 @@ +package resourcemutator + +import ( + "context" + "encoding/base64" + "fmt" + "net/http" + + "github.com/databricks/cli/bundle" + "github.com/databricks/cli/libs/diag" + "github.com/databricks/cli/libs/dyn" +) + +// maxAppThumbnailBytes matches the limit of the Apps UI and of the databricks_app +// Terraform resource, so all clients accept the same images. +const maxAppThumbnailBytes = 250_000 + +type configureAppThumbnail struct{} + +// ConfigureAppThumbnail reads the image at resources.apps.*.thumbnail_path, checks that it +// is a PNG or JPEG within the size limit, and stores it base64-encoded in thumbnail_content. +func ConfigureAppThumbnail() bundle.Mutator { + return &configureAppThumbnail{} +} + +func (c configureAppThumbnail) Name() string { + return "ConfigureAppThumbnail" +} + +func (c configureAppThumbnail) Apply(_ context.Context, b *bundle.Bundle) diag.Diagnostics { + var diags diag.Diagnostics + + pattern := dyn.NewPattern( + dyn.Key("resources"), + dyn.Key("apps"), + dyn.AnyKey(), + ) + + err := b.Config.Mutate(func(v dyn.Value) (dyn.Value, error) { + return dyn.MapByPattern(v, pattern, func(p dyn.Path, v dyn.Value) (dyn.Value, error) { + pathValue := v.Get("thumbnail_path") + thumbnailPath, ok := pathValue.AsString() + if !ok || thumbnailPath == "" { + return v, nil + } + + contents, err := b.SyncRoot.ReadFile(thumbnailPath) + if err != nil { + diags = diags.Append(diag.Diagnostic{ + Severity: diag.Error, + Summary: fmt.Sprintf("failed to read app thumbnail %s: %s", thumbnailPath, err), + Locations: pathValue.Locations(), + }) + return v, nil + } + + // The Apps API accepts only PNG and JPEG, detected by their file signatures. + contentType := http.DetectContentType(contents) + if contentType != "image/png" && contentType != "image/jpeg" { + diags = diags.Append(diag.Diagnostic{ + Severity: diag.Error, + Summary: fmt.Sprintf("app thumbnail %s must be a PNG or JPEG image, got %s", thumbnailPath, contentType), + Locations: pathValue.Locations(), + }) + return v, nil + } + + if len(contents) > maxAppThumbnailBytes { + diags = diags.Append(diag.Diagnostic{ + Severity: diag.Error, + Summary: fmt.Sprintf("app thumbnail %s is %d bytes, larger than the limit of %d bytes", thumbnailPath, len(contents), maxAppThumbnailBytes), + Locations: pathValue.Locations(), + }) + return v, nil + } + + return dyn.Set(v, "thumbnail_content", dyn.V(base64.StdEncoding.EncodeToString(contents))) + }) + }) + + return diags.Extend(diag.FromErr(err)) +} diff --git a/bundle/config/mutator/resourcemutator/configure_app_thumbnail_test.go b/bundle/config/mutator/resourcemutator/configure_app_thumbnail_test.go new file mode 100644 index 00000000000..c6963acdec9 --- /dev/null +++ b/bundle/config/mutator/resourcemutator/configure_app_thumbnail_test.go @@ -0,0 +1,98 @@ +package resourcemutator_test + +import ( + "bytes" + "encoding/base64" + "os" + "path/filepath" + "testing" + + "github.com/databricks/cli/bundle" + "github.com/databricks/cli/bundle/config" + "github.com/databricks/cli/bundle/config/mutator/resourcemutator" + "github.com/databricks/cli/bundle/config/resources" + "github.com/databricks/cli/libs/vfs" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +var ( + pngHeader = []byte("\x89PNG\r\n\x1a\n") + jpegHeader = []byte("\xff\xd8\xff\xe0") +) + +func padTo(header []byte, size int) []byte { + return append(bytes.Clone(header), make([]byte, size-len(header))...) +} + +func TestConfigureAppThumbnail(t *testing.T) { + tests := []struct { + name string + // contents is written to thumbnail.png when non-nil. + contents []byte + thumbnailPath string + wantErr string + }{ + {name: "png", contents: padTo(pngHeader, 100), thumbnailPath: "thumbnail.png"}, + {name: "jpeg", contents: padTo(jpegHeader, 100), thumbnailPath: "thumbnail.png"}, + {name: "png at the size limit", contents: padTo(pngHeader, 250_000), thumbnailPath: "thumbnail.png"}, + {name: "no thumbnail_path", thumbnailPath: ""}, + { + name: "png over the size limit", + contents: padTo(pngHeader, 250_001), + thumbnailPath: "thumbnail.png", + wantErr: "app thumbnail thumbnail.png is 250001 bytes, larger than the limit of 250000 bytes", + }, + { + name: "gif", + contents: padTo([]byte("GIF89a"), 100), + thumbnailPath: "thumbnail.png", + wantErr: "app thumbnail thumbnail.png must be a PNG or JPEG image, got image/gif", + }, + { + name: "empty file", + contents: []byte{}, + thumbnailPath: "thumbnail.png", + wantErr: "must be a PNG or JPEG image", + }, + { + name: "missing file", + thumbnailPath: "missing.png", + wantErr: "failed to read app thumbnail missing.png", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + dir := t.TempDir() + if tt.contents != nil { + require.NoError(t, os.WriteFile(filepath.Join(dir, "thumbnail.png"), tt.contents, 0o600)) + } + + app := &resources.App{ThumbnailPath: tt.thumbnailPath} + b := &bundle.Bundle{ + SyncRootPath: dir, + BundleRootPath: dir, + SyncRoot: vfs.MustNew(dir), + Config: config.Root{ + Resources: config.Resources{ + Apps: map[string]*resources.App{"my_app": app}, + }, + }, + } + + diags := bundle.ApplySeq(t.Context(), b, resourcemutator.ConfigureAppThumbnail()) + + if tt.wantErr != "" { + assert.ErrorContains(t, diags.Error(), tt.wantErr) + return + } + require.NoError(t, diags.Error()) + want := "" + if tt.contents != nil { + want = base64.StdEncoding.EncodeToString(tt.contents) + } + assert.Equal(t, want, b.Config.Resources.Apps["my_app"].ThumbnailContent) + }) + } +} diff --git a/bundle/config/mutator/resourcemutator/resource_mutator.go b/bundle/config/mutator/resourcemutator/resource_mutator.go index e00444cc773..4269a6aef7a 100644 --- a/bundle/config/mutator/resourcemutator/resource_mutator.go +++ b/bundle/config/mutator/resourcemutator/resource_mutator.go @@ -188,6 +188,10 @@ func applyNormalizeMutators(ctx context.Context, b *bundle.Bundle) { // Drops (dynamic): resources.dashboards.*.file_path ConfigureDashboardSerializedDashboard(), + // Reads (dynamic): resources.apps.*.thumbnail_path + // Updates (dynamic): resources.apps.*.thumbnail_content + ConfigureAppThumbnail(), + // Reads (dynamic): resources.genie_spaces.*.file_path // Updates (dynamic): resources.genie_spaces.*.serialized_space ConfigureGenieSpaceSerializedSpace(), diff --git a/bundle/config/resources/apps.go b/bundle/config/resources/apps.go index 76acbb29a96..15843dcb197 100644 --- a/bundle/config/resources/apps.go +++ b/bundle/config/resources/apps.go @@ -54,6 +54,12 @@ type App struct { // This allows users to define app configuration directly in the bundle YAML instead of maintaining a separate app.yaml file. Config *AppConfig `json:"config,omitempty"` + // ThumbnailPath is the local path of a PNG or JPEG image shown for the app in the Apps UI. + ThumbnailPath string `json:"thumbnail_path,omitempty"` + + // ThumbnailContent is the base64-encoded image read from ThumbnailPath (see ConfigureAppThumbnail). + ThumbnailContent string `json:"thumbnail_content,omitempty" bundle:"internal"` + Permissions []AppPermission `json:"permissions,omitempty"` } diff --git a/bundle/direct/dresources/app.go b/bundle/direct/dresources/app.go index f76681feb98..b34bbe704da 100644 --- a/bundle/direct/dresources/app.go +++ b/bundle/direct/dresources/app.go @@ -11,6 +11,7 @@ import ( "github.com/databricks/cli/bundle/appdeploy" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/bundle/deployplan" + "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/structs/structpath" "github.com/databricks/databricks-sdk-go" "github.com/databricks/databricks-sdk-go/apierr" @@ -20,11 +21,13 @@ import ( ) // AppState is the state type for App resources. source_code_path and git_source come from -// apps.App; config and lifecycle are DABs-only additions persisted in state. +// apps.App; config, lifecycle and thumbnail are DABs-only additions persisted in state. +// thumbnail is the base64-encoded image; state keeps only its hash (hashed_fields in apps.yml). type AppState struct { apps.App Config *resources.AppConfig `json:"config,omitempty"` Lifecycle *StateLifecycle `json:"lifecycle,omitempty"` + Thumbnail string `json:"thumbnail,omitempty"` } // AppRemote extends apps.App with the same DABs-only fields as AppState so they @@ -66,6 +69,7 @@ func (*ResourceApp) PrepareState(input *resources.App) *AppState { App: input.App, Config: input.Config, Lifecycle: nil, + Thumbnail: input.ThumbnailContent, } if input.Lifecycle != nil && input.Lifecycle.Started != nil { s.Lifecycle = &StateLifecycle{Started: input.Lifecycle.Started} @@ -82,6 +86,7 @@ func (*ResourceApp) RemapState(remote *AppRemote) *AppState { App: remote.App, Config: remote.Config, Lifecycle: remote.Lifecycle, + Thumbnail: "", } } @@ -160,9 +165,28 @@ func (r *ResourceApp) DoCreate(ctx context.Context, config *AppState) (string, * return "", nil, err } + // The thumbnail is uploaded before the state is saved, so a failed upload is not recorded + // and the next deploy retries it. Failing here would leave the new app out of the state. + if config.Thumbnail != "" { + if err := r.updateThumbnail(ctx, app.Name, config.Thumbnail); err != nil { + cmdio.LogString(ctx, fmt.Sprintf("Warning: failed to upload the thumbnail of app %s, the next deploy retries it: %s", app.Name, err)) + config.Thumbnail = "" + } + } + return app.Name, nil, nil } +func (r *ResourceApp) updateThumbnail(ctx context.Context, name, thumbnail string) error { + _, err := r.client.Apps.UpdateAppThumbnail(ctx, apps.UpdateAppThumbnailRequest{ + Name: name, + AppThumbnail: &apps.AppThumbnail{Thumbnail: thumbnail, ForceSendFields: nil}, + }) + return err +} + +var appThumbnailPath = structpath.MustParsePath("thumbnail") + var UpdateMaskFields = []string{ "description", "budget_policy_id", @@ -219,6 +243,18 @@ func (r *ResourceApp) doUpdate(ctx context.Context, id string, config *AppState, } } + if entry.Changes.HasChange(appThumbnailPath) { + var err error + if config.Thumbnail == "" { + err = r.client.Apps.DeleteAppThumbnail(ctx, apps.DeleteAppThumbnailRequest{Name: id}) + } else { + err = r.updateThumbnail(ctx, id, config.Thumbnail) + } + if err != nil { + return err + } + } + return r.manageLifecycle(ctx, id, config, remoteIsStarted(entry)) } @@ -282,7 +318,7 @@ func (r *ResourceApp) manageLifecycle(ctx context.Context, id string, config *Ap // hasAppChanges reports whether the plan entry contains any Update changes // to fields that belong to the App Update API (i.e., not deploy-only fields). func hasAppChanges(entry *PlanEntry) bool { - return entry.Changes.HasChangeExcept("source_code_path", "config", "git_source", "lifecycle", "lifecycle.started") + return entry.Changes.HasChangeExcept("source_code_path", "config", "git_source", "lifecycle", "lifecycle.started", "thumbnail") } // OverrideChangeDesc skips drift on the deploy-only fields (source_code_path, config, diff --git a/bundle/direct/dresources/configs/apps.yml b/bundle/direct/dresources/configs/apps.yml index 808a552cd15..14f19d30c70 100644 --- a/bundle/direct/dresources/configs/apps.yml +++ b/bundle/direct/dresources/configs/apps.yml @@ -25,3 +25,6 @@ ignore_remote_changes: reason: input_only - field: config.env[*].value_from reason: input_only +# "thumbnail" holds the base64-encoded image, so state keeps only its hash. +hashed_fields: + - thumbnail diff --git a/bundle/direct/dresources/type_test.go b/bundle/direct/dresources/type_test.go index d7515ae55a8..e867690bf5f 100644 --- a/bundle/direct/dresources/type_test.go +++ b/bundle/direct/dresources/type_test.go @@ -16,6 +16,10 @@ import ( // These are known issues that should be fixed. If a field listed here is found in RemoteType, // the test fails to ensure the entry is removed from this map. var knownMissingInRemoteType = map[string][]string{ + "apps": { + // The Apps API can't return the thumbnail image, only its thumbnail_url. + "thumbnail", + }, "external_locations": { "skip_validation", }, @@ -83,6 +87,8 @@ var knownMissingInStateType = map[string][]string{ "apps": { "lifecycle.prevent_destroy", "lifecycle.depends_on", + // The image read from thumbnail_path is kept in state as thumbnail. + "thumbnail_path", }, "clusters": { "lifecycle.prevent_destroy", diff --git a/bundle/internal/schema/annotations.yml b/bundle/internal/schema/annotations.yml index 58abf721658..1e6fb33a5e6 100644 --- a/bundle/internal/schema/annotations.yml +++ b/bundle/internal/schema/annotations.yml @@ -354,6 +354,9 @@ resources: "user_name": "description": |- The name of the user granted the permission level. + "thumbnail_path": + "description": |- + The local path of a PNG or JPEG image of at most 250 KB to show as the app's thumbnail in the Apps UI, relative to the file that defines the app. Removing it deletes the thumbnail. "catalogs": "description": |- PLACEHOLDER diff --git a/bundle/schema/jsonschema.json b/bundle/schema/jsonschema.json index 2d5a35b5a5e..aa60991a8fe 100644 --- a/bundle/schema/jsonschema.json +++ b/bundle/schema/jsonschema.json @@ -256,6 +256,10 @@ "$ref": "#/$defs/slice/github.com/databricks/databricks-sdk-go/service/apps.TelemetryExportDestination", "x-databricks-launch-stage": "GA" }, + "thumbnail_path": { + "description": "The local path of a PNG or JPEG image of at most 250 KB to show as the app's thumbnail in the Apps UI, relative to the file that defines the app. Removing it deletes the thumbnail.", + "$ref": "#/$defs/string" + }, "usage_policy_id": { "description": "[Public Preview] ID of the usage policy that the app's compute usage is attributed to. Alternative to\n`budget_policy_id`.", "$ref": "#/$defs/string", diff --git a/libs/testserver/apps.go b/libs/testserver/apps.go index 29bc70adc2a..34f9b31be0d 100644 --- a/libs/testserver/apps.go +++ b/libs/testserver/apps.go @@ -226,6 +226,33 @@ func (s *FakeWorkspace) AppsStop(_ Request, name string) Response { // AppsGet returns the app, keeping DELETING resources visible so callers can // observe transient state (matches the cloud DELETE lifecycle). +// AppsUpdateThumbnail sets thumbnail_url, the only trace of the image the real API returns. +func (s *FakeWorkspace) AppsUpdateThumbnail(name string) Response { + defer s.LockUnlock()() + + app, ok := s.Apps[name] + if !ok { + return Response{StatusCode: 404} + } + app.ThumbnailUrl = "/ajax-api/2.0/thumbnails/raw/apps/" + app.Id + "/SMALL_DEFAULT.png" + s.Apps[name] = app + + return Response{Body: apps.AppThumbnail{}} +} + +func (s *FakeWorkspace) AppsDeleteThumbnail(name string) Response { + defer s.LockUnlock()() + + app, ok := s.Apps[name] + if !ok { + return Response{StatusCode: 404} + } + app.ThumbnailUrl = "" + s.Apps[name] = app + + return Response{} +} + func (s *FakeWorkspace) AppsGet(name string) Response { defer s.LockUnlock()() diff --git a/libs/testserver/handlers.go b/libs/testserver/handlers.go index 20aac63e2b7..b7e6cf1ffd9 100644 --- a/libs/testserver/handlers.go +++ b/libs/testserver/handlers.go @@ -778,6 +778,14 @@ func AddDefaultHandlers(server *Server) { return req.Workspace.AppsGetUpdate(req, req.Vars["name"]) }) + server.Handle("PATCH", "/api/2.0/apps/{name}/thumbnail", func(req Request) any { + return req.Workspace.AppsUpdateThumbnail(req.Vars["name"]) + }) + + server.Handle("DELETE", "/api/2.0/apps/{name}/thumbnail", func(req Request) any { + return req.Workspace.AppsDeleteThumbnail(req.Vars["name"]) + }) + server.Handle("GET", "/api/2.0/apps/{name}", func(req Request) any { return req.Workspace.AppsGet(req.Vars["name"]) }) diff --git a/python/databricks/bundles/apps/_models/app.py b/python/databricks/bundles/apps/_models/app.py index baeb535cf2d..b1a78d42d6e 100644 --- a/python/databricks/bundles/apps/_models/app.py +++ b/python/databricks/bundles/apps/_models/app.py @@ -139,6 +139,11 @@ class App(Resource): effect when the app is next deployed. """ + thumbnail_path: VariableOrOptional[str] = None + """ + The local path of a PNG or JPEG image of at most 250 KB to show as the app's thumbnail in the Apps UI, relative to the file that defines the app. Removing it deletes the thumbnail. + """ + usage_policy_id: VariableOrOptional[str] = None """ [Public Preview] ID of the usage policy that the app's compute usage is attributed to. Alternative to @@ -258,6 +263,11 @@ class AppDict(TypedDict, total=False): effect when the app is next deployed. """ + thumbnail_path: VariableOrOptional[str] + """ + The local path of a PNG or JPEG image of at most 250 KB to show as the app's thumbnail in the Apps UI, relative to the file that defines the app. Removing it deletes the thumbnail. + """ + usage_policy_id: VariableOrOptional[str] """ [Public Preview] ID of the usage policy that the app's compute usage is attributed to. Alternative to From c670d2fca6ae95106922e8e2d4b4773b936be703 Mon Sep 17 00:00:00 2001 From: "fabian.jakobs" Date: Tue, 17 Nov 2026 17:09:51 +0000 Subject: [PATCH 2/4] Normalize the Windows missing-file error in thumbnail-invalid Co-authored-by: Isaac --- acceptance/bundle/resources/apps/thumbnail-invalid/test.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/acceptance/bundle/resources/apps/thumbnail-invalid/test.toml b/acceptance/bundle/resources/apps/thumbnail-invalid/test.toml index 1beb9c803b8..f01ded60648 100644 --- a/acceptance/bundle/resources/apps/thumbnail-invalid/test.toml +++ b/acceptance/bundle/resources/apps/thumbnail-invalid/test.toml @@ -1,2 +1,6 @@ RecordRequests = false Ignore = ["large.png"] + +[[Repls]] +Old = 'The system cannot find the file specified.' +New = 'no such file or directory' From cd10af6da8b0790611f4dd71197544dfe93f0ad7 Mon Sep 17 00:00:00 2001 From: "fabian.jakobs" Date: Wed, 18 Nov 2026 15:02:31 +0000 Subject: [PATCH 3/4] Address review: musterr, update_file.py, cloud coverage, doc comments Co-authored-by: Isaac --- .../resources/apps/thumbnail-invalid/out.test.toml | 2 +- .../resources/apps/thumbnail-invalid/output.txt | 12 +++--------- .../bundle/resources/apps/thumbnail-invalid/script | 2 +- .../resources/apps/thumbnail-invalid/test.toml | 1 + .../resources/apps/thumbnail-upload-fails/output.txt | 4 +--- .../resources/apps/thumbnail-upload-fails/script | 2 +- acceptance/bundle/resources/apps/thumbnail/script | 3 +-- acceptance/bundle/resources/apps/thumbnail/test.toml | 2 +- libs/testserver/apps.go | 5 +++-- 9 files changed, 13 insertions(+), 20 deletions(-) diff --git a/acceptance/bundle/resources/apps/thumbnail-invalid/out.test.toml b/acceptance/bundle/resources/apps/thumbnail-invalid/out.test.toml index a927a5fbc06..0f167effef1 100644 --- a/acceptance/bundle/resources/apps/thumbnail-invalid/out.test.toml +++ b/acceptance/bundle/resources/apps/thumbnail-invalid/out.test.toml @@ -1,2 +1,2 @@ -Cloud = false +Cloud = true EnvMatrix.DMS = ["", "true"] diff --git a/acceptance/bundle/resources/apps/thumbnail-invalid/output.txt b/acceptance/bundle/resources/apps/thumbnail-invalid/output.txt index fa404edfc95..bee13d5ac7c 100644 --- a/acceptance/bundle/resources/apps/thumbnail-invalid/output.txt +++ b/acceptance/bundle/resources/apps/thumbnail-invalid/output.txt @@ -1,7 +1,7 @@ === thumbnail_path: ./thumbnail.gif ->>> [CLI] bundle validate +>>> musterr [CLI] bundle validate Error: app thumbnail thumbnail.gif must be a PNG or JPEG image, got image/gif in databricks.yml:9:23 @@ -13,11 +13,9 @@ Workspace: Found 1 error -Exit code: 1 - === thumbnail_path: ./large.png ->>> [CLI] bundle validate +>>> musterr [CLI] bundle validate Error: app thumbnail large.png is 250001 bytes, larger than the limit of 250000 bytes in databricks.yml:9:23 @@ -29,11 +27,9 @@ Workspace: Found 1 error -Exit code: 1 - === thumbnail_path: ./missing.png ->>> [CLI] bundle validate +>>> musterr [CLI] bundle validate Error: failed to read app thumbnail missing.png: open missing.png: no such file or directory in databricks.yml:9:23 @@ -44,5 +40,3 @@ Workspace: Path: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default Found 1 error - -Exit code: 1 diff --git a/acceptance/bundle/resources/apps/thumbnail-invalid/script b/acceptance/bundle/resources/apps/thumbnail-invalid/script index 5be01607bc8..980a4a49fd5 100644 --- a/acceptance/bundle/resources/apps/thumbnail-invalid/script +++ b/acceptance/bundle/resources/apps/thumbnail-invalid/script @@ -5,5 +5,5 @@ for THUMBNAIL_PATH in ./thumbnail.gif ./large.png ./missing.png; do title "thumbnail_path: $THUMBNAIL_PATH" export THUMBNAIL_PATH envsubst < databricks.yml.tmpl > databricks.yml - errcode trace $CLI bundle validate + trace musterr $CLI bundle validate done diff --git a/acceptance/bundle/resources/apps/thumbnail-invalid/test.toml b/acceptance/bundle/resources/apps/thumbnail-invalid/test.toml index f01ded60648..01ca44e6cb1 100644 --- a/acceptance/bundle/resources/apps/thumbnail-invalid/test.toml +++ b/acceptance/bundle/resources/apps/thumbnail-invalid/test.toml @@ -1,4 +1,5 @@ RecordRequests = false +Cloud = true Ignore = ["large.png"] [[Repls]] diff --git a/acceptance/bundle/resources/apps/thumbnail-upload-fails/output.txt b/acceptance/bundle/resources/apps/thumbnail-upload-fails/output.txt index e51eff6218a..0278091c6ab 100644 --- a/acceptance/bundle/resources/apps/thumbnail-upload-fails/output.txt +++ b/acceptance/bundle/resources/apps/thumbnail-upload-fails/output.txt @@ -18,7 +18,7 @@ update apps.mykey Plan: 0 to add, 1 to change, 0 to delete, 0 unchanged ->>> [CLI] bundle deploy +>>> musterr [CLI] bundle deploy Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... Error: cannot update resources.apps.mykey: updating id=myappname: Unsupported image (400 INVALID_PARAMETER_VALUE) @@ -29,8 +29,6 @@ API message: Unsupported image Files: 0 uploaded, 0 deleted -Exit code: 1 - >>> [CLI] bundle destroy --auto-approve The following resources will be deleted: delete resources.apps.mykey diff --git a/acceptance/bundle/resources/apps/thumbnail-upload-fails/script b/acceptance/bundle/resources/apps/thumbnail-upload-fails/script index a7b045773e3..1c7508569e2 100644 --- a/acceptance/bundle/resources/apps/thumbnail-upload-fails/script +++ b/acceptance/bundle/resources/apps/thumbnail-upload-fails/script @@ -9,4 +9,4 @@ trace jq '.state["resources.apps.mykey"].state.thumbnail' .databricks/bundle/def title "The next deploy retries the upload" trace $CLI bundle plan -errcode trace $CLI bundle deploy +trace musterr $CLI bundle deploy diff --git a/acceptance/bundle/resources/apps/thumbnail/script b/acceptance/bundle/resources/apps/thumbnail/script index 9c4925c1b32..f83addb80cc 100644 --- a/acceptance/bundle/resources/apps/thumbnail/script +++ b/acceptance/bundle/resources/apps/thumbnail/script @@ -36,8 +36,7 @@ trace $CLI bundle deploy --plan tmp.plan.json trace print_requests.py //apps '^//api/2.0/bundle' | jq -r '.body.app_thumbnail.thumbnail | .[0:12]' title "Remove thumbnail_path: the thumbnail is deleted" -grep -v thumbnail_path databricks.yml > databricks.yml.new -mv databricks.yml.new databricks.yml +update_file.py databricks.yml $' thumbnail_path: ./thumbnail.png\n' '' trace $CLI bundle plan trace $CLI bundle deploy trace print_requests >> out.requests.json diff --git a/acceptance/bundle/resources/apps/thumbnail/test.toml b/acceptance/bundle/resources/apps/thumbnail/test.toml index ac9587743bc..81f10da5319 100644 --- a/acceptance/bundle/resources/apps/thumbnail/test.toml +++ b/acceptance/bundle/resources/apps/thumbnail/test.toml @@ -1 +1 @@ -Ignore = [".databricks", "thumbnail.png", "databricks.yml.new", "tmp.plan.json"] +Ignore = [".databricks", "thumbnail.png", "tmp.plan.json"] diff --git a/libs/testserver/apps.go b/libs/testserver/apps.go index 34f9b31be0d..a014e9ac372 100644 --- a/libs/testserver/apps.go +++ b/libs/testserver/apps.go @@ -224,8 +224,6 @@ func (s *FakeWorkspace) AppsStop(_ Request, name string) Response { return Response{Body: app} } -// AppsGet returns the app, keeping DELETING resources visible so callers can -// observe transient state (matches the cloud DELETE lifecycle). // AppsUpdateThumbnail sets thumbnail_url, the only trace of the image the real API returns. func (s *FakeWorkspace) AppsUpdateThumbnail(name string) Response { defer s.LockUnlock()() @@ -240,6 +238,7 @@ func (s *FakeWorkspace) AppsUpdateThumbnail(name string) Response { return Response{Body: apps.AppThumbnail{}} } +// AppsDeleteThumbnail clears thumbnail_url. func (s *FakeWorkspace) AppsDeleteThumbnail(name string) Response { defer s.LockUnlock()() @@ -253,6 +252,8 @@ func (s *FakeWorkspace) AppsDeleteThumbnail(name string) Response { return Response{} } +// AppsGet returns the app, keeping DELETING resources visible so callers can +// observe transient state (matches the cloud DELETE lifecycle). func (s *FakeWorkspace) AppsGet(name string) Response { defer s.LockUnlock()() From 857464df38a25165cb3bbca206e2c58f551ad3db Mon Sep 17 00:00:00 2001 From: "fabian.jakobs" Date: Wed, 18 Nov 2026 16:34:23 +0000 Subject: [PATCH 4/4] Record source_code_path in app create body after merge with main Co-authored-by: Isaac --- acceptance/bundle/resources/apps/thumbnail/out.requests.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/acceptance/bundle/resources/apps/thumbnail/out.requests.json b/acceptance/bundle/resources/apps/thumbnail/out.requests.json index dee2b2323b4..8b5e958b16f 100644 --- a/acceptance/bundle/resources/apps/thumbnail/out.requests.json +++ b/acceptance/bundle/resources/apps/thumbnail/out.requests.json @@ -6,7 +6,8 @@ }, "body": { "description": "", - "name": "myappname" + "name": "myappname", + "source_code_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files/app" } } {