Repository navigation
fix(ec2): report an instance's security groups as groupSet (#444) - #449
Merged
Merged
Conversation
RunInstances and DescribeInstances accepted security groups on a launch, validated them against the subnet's VPC and stored them — then omitted them from every read. A consumer that launched an instance with an explicit security group read back an instance with no groups at all. Nothing errored; the fact was simply missing, which reads as "this instance has no security groups" rather than "substrate didn't report them". Both responses now emit groupSet>item with groupId and groupName, matching AWS's GroupIdentifier, for groups from any source: the request, the launch template's network interface, or the default VPC's default group. groupName is omitted when the group cannot be resolved. A group deleted after the launch keeps reporting its groupId, since that is what the launch actually recorded, rather than being handed an invented name — a fabricated name is the same class of confident-wrong-answer as the missing field. The two response builders had each declared their own instance item type, which is how a field could go missing from both at once. They now share the group item so they cannot disagree about its shape.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This was referenced Aug 1, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #444.
Second and final half of #444. #448 carried the launch-template network interface; this carries the
groupSet, and is what makes the template's security groups observable at all.The defect
RunInstancesaccepted security groups, validated them against the subnet's VPC, and stored them on the instance (inst.SecurityGroupIDs) — then neitherRunInstancesnorDescribeInstancesemitted them. A consumer that launched an instance with an explicit security group read back an instance with no groups.Nothing errored. The 200 was correct, the instance was correct, and the fact was simply absent — which reads as "this instance has no security groups" rather than "substrate didn't report them", so the consumer debugs their own code first. Same shape as the rest of this batch: a missing fact, not a missing error.
The fix
Both responses emit
groupSet>itemwithgroupIdandgroupName, matching AWS'sGroupIdentifier, for groups from any source — the request, the launch template's network interface, or the default VPC'sdefaultgroup.groupNameis omitted when the group cannot be resolved. A group deleted after the launch keeps reporting itsgroupId, since that is what the launch actually recorded, rather than being handed an invented name. A fabricated name is the same class of confident-wrong-answer this batch exists to remove.The two response builders had each declared their own instance item type, which is how a field could go missing from both at once. They now share
ec2GroupItemand a singleec2GroupItemshelper, so they cannot disagree about the shape.Tests
TestEC2_Instances_GroupSetasserts both responses in every case — one populated and the other empty is exactly the drift that produced the gap:SecurityGroupId.1, with its name resolved;defaultgroup, when the launch names none;groupNameabsent after the group is deleted, withgroupIdstill reported.Two assertions removed from #448 for being ahead of the code are restored here.
Mutation-tested three ways: removing either emission fails that response's assertions independently; removing the name lookup fails only the four name assertions, leaving the deleted-group case green — so the ID and the name are separately covered.
Verification
gofmt,go build,go vet,golangci-lint run ./...(0 issues),make test(race),test/e2e,make docs-reference-check docs-versions— all clean, re-run after rebasing onto the merged #448.