Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
RESERVED_COLON_KEYWORD = "__reserved__colon__"
RESERVED_ARROW_KEYWORD = "__reserved__arrow__"
RESERVED_QUOTE_KEYWORD = "__reserved__quote__"
RESERVED_NEWLINE_KEYWORD = "__reserved__newline__"
RESERVED_CARRIAGE_RETURN_KEYWORD = "__reserved__carriage_return__"
RESERVED_TAB_KEYWORD = "__reserved__tab__"


class TransformDirection(Enum):
Expand Down Expand Up @@ -115,6 +118,9 @@
value.replace(RESERVED_COLON_KEYWORD, "::")
.replace(RESERVED_ARROW_KEYWORD, ">")
.replace(RESERVED_QUOTE_KEYWORD, '"')
.replace(RESERVED_NEWLINE_KEYWORD, "\n")
.replace(RESERVED_CARRIAGE_RETURN_KEYWORD, "\r")
.replace(RESERVED_TAB_KEYWORD, "\t")
)


Expand All @@ -123,6 +129,9 @@
value.replace("::", RESERVED_COLON_KEYWORD)
.replace(">", RESERVED_ARROW_KEYWORD)
.replace('"', RESERVED_QUOTE_KEYWORD)
.replace("\n", RESERVED_NEWLINE_KEYWORD)
.replace("\r", RESERVED_CARRIAGE_RETURN_KEYWORD)
.replace("\t", RESERVED_TAB_KEYWORD)
Comment thread
harshsoni2024 marked this conversation as resolved.
Comment thread
harshsoni2024 marked this conversation as resolved.
)


Expand Down Expand Up @@ -174,7 +183,7 @@
if hasattr(constraint, "columns"):
constraint.columns = [transformer(col) for col in constraint.columns]

if transformer == replace_separators and type(name) == str: # noqa: E721

Check warning on line 186 in ingestion/src/metadata/ingestion/models/custom_basemodel_validation.py

View check run for this annotation

SonarQubeCloud / [open-metadata-ingestion] SonarCloud Code Analysis

Use the `isinstance()` function here.

See more on https://sonarcloud.io/project/issues?id=open-metadata-ingestion&issues=AZ4l2JTeMSN_QC76bXmW&open=AZ4l2JTeMSN_QC76bXmW&pullRequest=28092
obj.name = transformer(name)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@
logger.warning(f"Error converting regex '{regex}' to OData condition: {exc}")
return ""

def create_filter_query(self, filter_pattern) -> Optional[str]: # noqa: UP045

Check failure on line 342 in ingestion/src/metadata/ingestion/source/dashboard/powerbi/client.py

View check run for this annotation

SonarQubeCloud / [open-metadata-ingestion] SonarCloud Code Analysis

Refactor this function to reduce its Cognitive Complexity from 19 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=open-metadata-ingestion&issues=AZ4hmrq6pvLO0oDBsyBO&open=AZ4hmrq6pvLO0oDBsyBO&pullRequest=28092
"""
Create a complete filter query for workspaces from filter_pattern
"""
Expand Down Expand Up @@ -379,7 +379,7 @@
return None

# pylint: disable=too-many-branches,too-many-statements
def fetch_all_workspaces(self, filter_pattern: Optional[FilterPattern] = None) -> Optional[List[Group]]: # noqa: C901, UP006, UP045

Check failure on line 382 in ingestion/src/metadata/ingestion/source/dashboard/powerbi/client.py

View check run for this annotation

SonarQubeCloud / [open-metadata-ingestion] SonarCloud Code Analysis

Refactor this function to reduce its Cognitive Complexity from 39 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=open-metadata-ingestion&issues=AZ4hmrq6pvLO0oDBsyBP&open=AZ4hmrq6pvLO0oDBsyBP&pullRequest=28092
"""Method to fetch all powerbi workspace details
Returns:
Group
Expand Down Expand Up @@ -542,19 +542,41 @@
return None

def fetch_workspace_scan_result(self, scan_id: str) -> Optional[Workspaces]: # noqa: UP045
"""Get Workspace scan result by id method
Args:
scan_id:
Returns:
Workspaces
"""Get Workspace scan result by id method.

Parse each workspace individually so a single malformed workspace
(or any nested entity that still fails validation) does not invalidate
the whole scan-result response and drop the entire chunk of workspaces.
"""
try:
logger.debug(
f"Calling the API({str(self.client._base_url)}/myorg/admin/workspaces/scanResult/{scan_id})" # pylint: disable=protected-access # noqa: RUF010
" to get workspace scan result"
)
Comment thread
harshsoni2024 marked this conversation as resolved.
response_data = self.client.get(f"/myorg/admin/workspaces/scanResult/{scan_id}")
return Workspaces(**response_data)
if not response_data:
return None
Comment thread
harshsoni2024 marked this conversation as resolved.
parsed_workspaces: List[Group] = [] # noqa: UP006
for raw_ws in response_data.get("workspaces", []) or []: # pyright: ignore[reportAttributeAccessIssue]
if isinstance(raw_ws, dict) and raw_ws.get("id") is not None:
try:
parsed_workspaces.append(Group(**raw_ws))
except Exception as ws_exc: # pylint: disable=broad-except
logger.debug(traceback.format_exc())
logger.warning(
"Skipping workspace [id=%s] in scan [%s] due to parse error: %s",
raw_ws.get("id"),
scan_id,
ws_exc,
)
else:
workspace_entry_type = type(raw_ws).__name__
logger.warning(
"Skipping a workspace in scan [%s] due to missing 'id' field or invalid format. Entry type: %s",
scan_id,
workspace_entry_type,
Comment thread
harshsoni2024 marked this conversation as resolved.
)
return Workspaces(workspaces=parsed_workspaces)
except Exception as exc: # pylint: disable=broad-except
logger.debug(traceback.format_exc())
logger.warning(f"Error fetching workspace scan result: {exc}")
Expand Down Expand Up @@ -616,4 +638,4 @@
model_config = ConfigDict(arbitrary_types_allowed=True)

api_client: PowerBiApiClient
file_client: Optional[PowerBiFileClient] # noqa: UP045

Check failure on line 641 in ingestion/src/metadata/ingestion/source/dashboard/powerbi/client.py

View check run for this annotation

SonarQubeCloud / [open-metadata-ingestion] SonarCloud Code Analysis

Add an explicit default value to this optional field.

See more on https://sonarcloud.io/project/issues?id=open-metadata-ingestion&issues=AZ4hmrq6pvLO0oDBsyBQ&open=AZ4hmrq6pvLO0oDBsyBQ&pullRequest=28092
Loading
Loading