Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use .get with defaults instead of [] to avoid ApiAttributeError on missing timeStamp or message. PAASTA-17100 #2966

Merged
merged 1 commit into from Nov 3, 2020

Conversation

EvanKrall
Copy link
Member

No description provided.

Copy link
Contributor

@mks-m mks-m left a comment

Choose a reason for hiding this comment

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

minor nit

@@ -1912,7 +1913,11 @@ def format_pod_event_messages(
rows: List[str] = list()
rows.append(PaastaColors.blue(f"Pod Events for {pod_name}"))
for message in pod_event_messages:
rows.append(f" Event at {message['timeStamp']}: {message['message']}")
Copy link
Contributor

Choose a reason for hiding this comment

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

no need to catch exception here, you should be able to use .get:

rows.append(f"   Event at {message.get('timeStamp', 'unknown time')}: {message['message']}")

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks, didn't know about that.

@EvanKrall EvanKrall reopened this Nov 3, 2020
@EvanKrall EvanKrall changed the title Catch ApiAttributeError on missing timestamp attribute, PAASTA-17100 Use .get with defaults instead of [] to avoid ApiAttributeError on mi… 0f5dfad …ssing timeStamp or message. PAASTA-17100 Nov 3, 2020
@EvanKrall EvanKrall changed the title Use .get with defaults instead of [] to avoid ApiAttributeError on mi… 0f5dfad …ssing timeStamp or message. PAASTA-17100 Use .get with defaults instead of [] to avoid ApiAttributeError on missing timeStamp or message. PAASTA-17100 Nov 3, 2020
@EvanKrall EvanKrall merged commit 578a2b4 into master Nov 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants