From 25a7e0a72b8fff23b227e6e129fdc8f770134cc4 Mon Sep 17 00:00:00 2001 From: shreyas-goenka <88374338+shreyas-goenka@users.noreply.github.com> Date: Mon, 3 Mar 2025 17:33:46 +0530 Subject: [PATCH] Do not use `.MustString()` in auth interpolation warning (#2412) ## Why Addresses post merge feedback from https://github.com/databricks/cli/pull/2399#discussion_r1975091730 ## Tests N/A --- .../validate/interpolation_in_auth_config.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/bundle/config/validate/interpolation_in_auth_config.go b/bundle/config/validate/interpolation_in_auth_config.go index 83d6c6ae1..1a5b64a26 100644 --- a/bundle/config/validate/interpolation_in_auth_config.go +++ b/bundle/config/validate/interpolation_in_auth_config.go @@ -24,7 +24,10 @@ func (f *noInterpolationInAuthConfig) Name() string { func (f *noInterpolationInAuthConfig) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics { authFields := []string{ // Generic attributes. - "host", "profile", "auth_type", "metadata_service_url", + "host", + "profile", + "auth_type", + "metadata_service_url", // OAuth specific attributes. "client_id", @@ -33,8 +36,12 @@ func (f *noInterpolationInAuthConfig) Apply(ctx context.Context, b *bundle.Bundl "google_service_account", // Azure specific attributes. - "azure_resource_id", "azure_use_msi", "azure_client_id", "azure_tenant_id", - "azure_environment", "azure_login_app_id", + "azure_resource_id", + "azure_use_msi", + "azure_client_id", + "azure_tenant_id", + "azure_environment", + "azure_login_app_id", } diags := diag.Diagnostics{} @@ -49,12 +56,11 @@ func (f *noInterpolationInAuthConfig) Apply(ctx context.Context, b *bundle.Bundl return diag.FromErr(err) } - if v.Kind() == dyn.KindInvalid || v.Kind() == dyn.KindNil { + vv, ok := v.AsString() + if !ok { continue } - vv := v.MustString() - // Check if the field contains interpolation. if dynvar.ContainsVariableReference(vv) { envVar, ok := auth.GetEnvFor(fieldName)