Skip to content
Merged
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
6 changes: 2 additions & 4 deletions airflow/providers/amazon/aws/hooks/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ def get_log_events(
| 'ingestionTime' (int): The time in milliseconds the event was ingested.
"""
next_token = None

event_count = 1
while event_count > 0:
while True:
if next_token is not None:
token_arg: Optional[Dict[str, str]] = {'nextToken': next_token}
else:
Expand All @@ -99,7 +97,7 @@ def get_log_events(

yield from events

if 'nextForwardToken' in response:
if next_token != response['nextForwardToken']:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use response.get('nextForwardToken', None) to avoid any chance of a KeyError here, or do we know for sure that will always be included in the response?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably OK to just fail if the response format changes. An exception raised here (assuming the hook is used in a DAG) would eventually be caught by the test runner and logged to the task logs, which would clearly signal the problem (the API has an unexpected change in format). If we silently fall back to None, it would be more difficult to debug later if the API changed format unexpected (missing nextForwardToken), or actually returned "nextForwardToken": null (which is expected and signals a valid scenario, indicating we or the user may have logical bugs in the workflow).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ferruzzi @uranusjr Is there any change required in this PR or is it good to go?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uranusjr covered my concern, but I'm also not a committer so my approval doesn't carry much (any) weight.

next_token = response['nextForwardToken']
else:
return