Ignore metastore permission error during template generation (#1819)

## Changes

This extends the `{{default_catalog}}` helper in templates to ignore any
`PERMISSION_DENIED` error. We're still reviewing when exactly this error
occurs, but if it does, it should not break templates. We should fall
back to assuming there's no default catalog (and no UC) instead.

## Testing

I have not been able to reproduce this issue, but there is a customer
report about "access denied to clusters that don't have unity catalog
enabled" being returned on a non-UC workspace. The error code in this PR
corresponds to that message.

## Next steps
We'll work together with the UC team to review if this error even makes
sense for this API. If that discussion leads to a behavior change in the
API we can update the CLI code again.
This commit is contained in:
Lennart Kats (databricks) 2024-10-11 14:28:56 +02:00 committed by GitHub
parent 845d23ac21
commit 08a0d083c3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -128,8 +128,8 @@ func loadHelpers(ctx context.Context) template.FuncMap {
metastore, err := w.Metastores.Current(ctx) metastore, err := w.Metastores.Current(ctx)
if err != nil { if err != nil {
var aerr *apierr.APIError var aerr *apierr.APIError
if errors.As(err, &aerr) && aerr.ErrorCode == "METASTORE_DOES_NOT_EXIST" { if errors.As(err, &aerr) && (aerr.ErrorCode == "PERMISSION_DENIED" || aerr.ErrorCode == "METASTORE_DOES_NOT_EXIST") {
// Workspace doesn't have a metastore assigned, ignore error // Ignore: access denied or workspace doesn't have a metastore assigned
empty_default := "" empty_default := ""
cachedCatalog = &empty_default cachedCatalog = &empty_default
return "", nil return "", nil