Fix powerbi test connection sucess with bad credentials (#19730)

This commit is contained in:
Suman Maharana 2025-02-11 13:49:21 +05:30 committed by GitHub
parent 0733cee6a2
commit c43fa48d18
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -94,7 +94,7 @@ class PowerBiApiClient:
auth_response = PowerBiToken(**response_data) auth_response = PowerBiToken(**response_data)
if not auth_response.access_token: if not auth_response.access_token:
raise InvalidSourceException( raise InvalidSourceException(
"Failed to generate the PowerBi access token. Please check provided config" f"Failed to generate the PowerBi access token. Please check provided config {response_data}"
) )
logger.info("PowerBi Access Token generated successfully") logger.info("PowerBi Access Token generated successfully")
@ -105,19 +105,12 @@ class PowerBiApiClient:
Returns: Returns:
List[PowerBIDashboard] List[PowerBIDashboard]
""" """
try: if self.config.useAdminApis:
if self.config.useAdminApis: response_data = self.client.get("/myorg/admin/dashboards")
response_data = self.client.get("/myorg/admin/dashboards") response = DashboardsResponse(**response_data)
response = DashboardsResponse(**response_data) return response.value
return response.value group = self.fetch_all_workspaces()[0]
group = self.fetch_all_workspaces()[0] return self.fetch_all_org_dashboards(group_id=group.id)
return self.fetch_all_org_dashboards(group_id=group.id)
except Exception as exc: # pylint: disable=broad-except
logger.debug(traceback.format_exc())
logger.warning(f"Error fetching dashboards: {exc}")
return None
def fetch_all_org_dashboards( def fetch_all_org_dashboards(
self, group_id: str self, group_id: str