fix: Handle bad permission errors for bigquery test connections (#14147)

* starter make file

* yea

* move messaging to config

* Delete Makefile

* remove

* checkout

* check for db generic errors

* checkout bad files

* add proper message

* add docs for new permissions codes

* Update superset/errors.py

Co-authored-by: AAfghahi <48933336+AAfghahi@users.noreply.github.com>

* Update superset/errors.py

Co-authored-by: AAfghahi <48933336+AAfghahi@users.noreply.github.com>

* rename var

* starter regex

* fix

* fix

* fix linting

* update test

* yerp

* fixed test

* added regex

* Apply suggestions from code review

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>

* address comments

* update docs

* prettier

* fux

* add space

* Update errors.py

* Update types.ts

Co-authored-by: AAfghahi <48933336+AAfghahi@users.noreply.github.com>
Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>
This commit is contained in:
Hugh A. Miles II
2021-04-20 19:19:36 -04:00
committed by GitHub
parent ff665fa5a7
commit 392d8a8107
6 changed files with 57 additions and 1 deletions

View File

@@ -20,16 +20,24 @@ from datetime import datetime
from typing import Any, Dict, List, Optional, Tuple, TYPE_CHECKING
import pandas as pd
from flask_babel import gettext as __
from sqlalchemy import literal_column
from sqlalchemy.sql.expression import ColumnClause
from superset.db_engine_specs.base import BaseEngineSpec
from superset.errors import SupersetErrorType
from superset.utils import core as utils
if TYPE_CHECKING:
from superset.models.core import Database # pragma: no cover
CONNECTION_DATABASE_PERMISSIONS_REGEX = re.compile(
"Access Denied: Project User does not have bigquery.jobs.create "
+ "permission in project (?P<project>.+?)"
)
class BigQueryEngineSpec(BaseEngineSpec):
"""Engine spec for Google's BigQuery
@@ -86,6 +94,17 @@ class BigQueryEngineSpec(BaseEngineSpec):
"P1Y": "{func}({col}, YEAR)",
}
custom_errors = {
CONNECTION_DATABASE_PERMISSIONS_REGEX: (
__(
"We were unable to connect to your database. Please "
"confirm that your service account has the Viewer "
"and Job User roles on the project."
),
SupersetErrorType.CONNECTION_DATABASE_PERMISSIONS_ERROR,
),
}
@classmethod
def convert_dttm(cls, target_type: str, dttm: datetime) -> Optional[str]:
tt = target_type.upper()