andreas-thomik commented on issue #51429:
URL: https://github.com/apache/airflow/issues/51429#issuecomment-2948673390
The failure comes from the code you identified earlier, where we try to
access the first element of the `containers` list without checking if it exists.
```python
if not self.container_name:
self.container_name = response["tasks"][0]["containers"][0]["name"]
```
My suggestions would be to:
1. Add a check in the code above and set `self.container_name = None` if it
fails
1. Issue a warning to the user if the container name cannot be inferred from
the response **and** no `/` exists in the `awslogs_stream_prefix` provided by
the user.
- Note also that getting the container name is entirely un-necessary if
the user has not provided `awslogs_stream_prefix` since in that case we don't
care about logging anyway.
1. (Optional) Graciously handle exceptions in
[get_last_log_messages](https://github.com/apache/airflow/blob/main/providers/amazon/src/airflow/providers/amazon/aws/utils/task_log_fetcher.py#L108)
to make it consistent with the behaviour in
[_get_log_events](https://github.com/apache/airflow/blob/main/providers/amazon/src/airflow/providers/amazon/aws/utils/task_log_fetcher.py#L78)
Happy to open a PR if you agree @dominikhei
--
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]