Skip to content

ensure non-nil Attachment in getENIAttachmentID#915

Merged
mogren merged 1 commit intoaws:masterfrom
jaypipes:issue914
Apr 17, 2020
Merged

ensure non-nil Attachment in getENIAttachmentID#915
mogren merged 1 commit intoaws:masterfrom
jaypipes:issue914

Conversation

@jaypipes
Copy link
Copy Markdown
Contributor

@jaypipes jaypipes commented Apr 17, 2020

Practice good code safety in the EC2MetadataCache.getENIAttachmentID() method
by not assuming that either the DescribeNetworkInterfacesOutput
struct's NetworkInterfaces field is not empty and that the first
NetworkInterface struct in that collection has a non-nil Attachment
field.

Fixes Issue #914

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Practice good code safety in the `EC2MetadataCache.getENIAttachmentID()`
method by not assuming that either the `DescribeNetworkInterfacesOutput`
struct's `NetworkInterfaces` field is not empty and that the first
`NetworkInterface` struct that collection has a non-nil `Attachment`
field.

Fixes Issue aws#914 however note that with aws#909, the source code changed
dramatically and this patch will need to be written differently for
v1.5.x branches.
@jaypipes jaypipes changed the title ensure non-nil Attachement in DescribeENI ensure non-nil Attachment in getENIAttachmentID Apr 17, 2020
Copy link
Copy Markdown
Contributor

@mogren mogren left a comment

Choose a reason for hiding this comment

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

LGTM! 👍

assert.Error(t, err)
}

func TestGetENIAttachmentID(t *testing.T) {
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.

Nice!

@mogren mogren added the bug label Apr 17, 2020
@mogren mogren merged commit 9c86334 into aws:master Apr 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants