dabla commented on code in PR #74600:
URL: https://github.com/apache/airflow/pull/74600#discussion_r4297198444
##########
providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/powerbi.py:
##########
@@ -187,6 +196,47 @@ async def get_refresh_details_by_refresh_id(
refresh_details = refresh_histories[refresh_ids.index(refresh_id)]
+ if refresh_details.get(PowerBIDatasetRefreshFields.REFRESH_TYPE.value)
== self.VIA_ENHANCED_API:
+ try:
+ execution_details = await self.run(
+
url="myorg/groups/{group_id}/datasets/{dataset_id}/refreshes/{refresh_id}",
+ path_parameters={
+ "group_id": group_id,
+ "dataset_id": dataset_id,
+ "refresh_id": refresh_id,
+ },
+ )
+ except AirflowException as error:
+ raise PowerBIDatasetRefreshException(
+ "Failed to retrieve refresh execution details"
+ ) from error
+ status = execution_details.get("extendedStatus")
+ if status not in (
+ PowerBIDatasetRefreshStatus.TERMINAL_STATUSES
+ | PowerBIDatasetRefreshStatus.ACTIVE_EXTENDED_STATUSES
+ ):
+ status = execution_details.get("status")
+ errors = [
+ message["message"]
+ for message in execution_details.get("messages", [])
Review Comment:
**[nit]** A `null` `messages` or `refreshAttempts` still ends the same way
as the missing `message` key did.
`execution_details.get("messages", [])` falls back to `[]` only when the key
is absent. When the response has `"messages": null`, `.get` returns `None`, and
iterating over it raises `TypeError`. As with the earlier `KeyError`, that is
not a `PowerBIDatasetRefreshException`, so it goes to `PowerBITrigger.run`'s
`except Exception`, which cancels the running refresh. The `refreshAttempts`
read at line 228 has the same problem.
The API reference doesn't say these arrays can be `null`, but guarding
against it costs one `or` each:
```python
for message in execution_details.get("messages") or []
...
for attempt in execution_details.get("refreshAttempts") or []
```
A `"messages": None` case in `test_enhanced_refresh_optional_message_text`
would cover it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]