You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
RunInstances: validate required parameters (ImageId) like AWS does #412
EC2Plugin.runInstances reads ImageId (emulator/ec2_plugin.go ~L230) but never validates it's non-empty. Real EC2 RunInstances rejects a call with no ImageId (and no launch template supplying one) with MissingParameter. Substrate accepts it and returns a running instance. Other required params in the same plugin are validated (KeyName, VpcId, CidrBlock, InstanceId all return MissingParameter/InvalidParameterValue), so this is a fidelity gap, not a design boundary — squarely "request/response error-code accuracy" per scope.md.
Why this matters (concrete)
In spore-host/spawn#70, the pool's worker-launch path built a LaunchConfig with an empty AMI (it bypassed the AMI auto-detect that the normal launch path does). On real AWS every worker failed with MissingParameter; against Substrate the launch "succeeded", so the bug shipped and only a paid smoke caught it. Validating ImageId would have turned this into a unit-test failure.
Proposed
In runInstances, when ImageId is empty AND no launch template / template ImageId resolves one, return:
&AWSError{Code: "MissingParameter", Message: "The request must contain the parameter ImageId", HTTPStatus: 400}
Mirror AWS wording where practical. Consider a quick pass for any other RunInstances params AWS treats as required so the emulator's reject-set matches (ImageId is the high-value one for the launch path).
Acceptance
RunInstances with no ImageId (and no template supplying one) → MissingParameter, HTTP 400.
RunInstances with a valid ImageId (or a launch template that carries one) → unchanged.
Scope note
Error-code fidelity on an existing operation; no workload execution. Consistent with the required-parameter validation the plugin already does elsewhere.
Fixed and closed by #425 (v0.81.0, unreleased). RunInstances now rejects a launch
that resolves no AMI with MissingParameter / "The request must contain the parameter
ImageId" / HTTP 400 — the exact shape you asked for, via the existing ec2MissingParameter helper.
The check runs after launch-template resolution, not on request entry. AWS
documents ImageId as "Required: No" precisely because a launch template may supply
it, so a check at the top would reject a valid launch that names a template carrying
an AMI. Positioned post-resolution, the condition reads as the actual AWS rule: no
AMI resolved from any source. Test rows pin both directions, including the case
where a template resolves but carries no ImageId (400 — nothing resolved).
Scope is strictly emptiness — no ami- format validation. There's no image-ID kind
in the resource-ID validator today and around a dozen existing tests use non-hex IDs
like ami-base and ami-test; adding format checks is a separate decision.
On the "quick pass for other required parameters" — declining, and why it's not arbitrary
AWS marks only MinCount and MaxCount as required on RunInstances, and in every
typed SDK those are required members: int32 in Go, required kwargs in botocore's
validation layer. A consumer bug there fails client-side and never reaches the wire,
so validating them here would catch a bug class that is already unreachable — while
breaking hand-built form-encoded requests, which is what a good number of substrate's
own tests are.
ImageId is different in a way that is the whole reason your bug shipped: it's an
optional *string, so aws.String("") serializes as absent from the wire and
reaches the service. Client-side validation cannot catch it; only the service can.
That asymmetry — optional-typed but service-required-in-effect — is where the real
fidelity gaps live, and it's a better filter for "what should substrate validate"
than the required/optional column in the docs.
There is a non-breaking version of your suggestion, though, and it's worth doing:
reject MinCount/MaxCount that are present but unparseable or < 1 with InvalidParameterValue, while leaving absence defaulted as it is now. That catches
a real wire-reachable mistake without breaking anything that omits them. I'll file it
separately rather than widen this issue.
Activity
scttfrdmn commentedon Aug 1, 2026
Fixed and closed by #425 (v0.81.0, unreleased).
RunInstancesnow rejects a launchthat resolves no AMI with
MissingParameter/ "The request must contain the parameterImageId" / HTTP 400 — the exact shape you asked for, via the existing
ec2MissingParameterhelper.The check runs after launch-template resolution, not on request entry. AWS
documents
ImageIdas "Required: No" precisely because a launch template may supplyit, so a check at the top would reject a valid launch that names a template carrying
an AMI. Positioned post-resolution, the condition reads as the actual AWS rule: no
AMI resolved from any source. Test rows pin both directions, including the case
where a template resolves but carries no
ImageId(400 — nothing resolved).Scope is strictly emptiness — no
ami-format validation. There's no image-ID kindin the resource-ID validator today and around a dozen existing tests use non-hex IDs
like
ami-baseandami-test; adding format checks is a separate decision.On the "quick pass for other required parameters" — declining, and why it's not arbitrary
AWS marks only
MinCountandMaxCountas required onRunInstances, and in everytyped SDK those are required members:
int32in Go, required kwargs in botocore'svalidation layer. A consumer bug there fails client-side and never reaches the wire,
so validating them here would catch a bug class that is already unreachable — while
breaking hand-built form-encoded requests, which is what a good number of substrate's
own tests are.
ImageIdis different in a way that is the whole reason your bug shipped: it's anoptional
*string, soaws.String("")serializes as absent from the wire andreaches the service. Client-side validation cannot catch it; only the service can.
That asymmetry — optional-typed but service-required-in-effect — is where the real
fidelity gaps live, and it's a better filter for "what should substrate validate"
than the required/optional column in the docs.
There is a non-breaking version of your suggestion, though, and it's worth doing:
reject
MinCount/MaxCountthat are present but unparseable or < 1 withInvalidParameterValue, while leaving absence defaulted as it is now. That catchesa real wire-reachable mistake without breaking anything that omits them. I'll file it
separately rather than widen this issue.
chore(release): v0.81.0 (#432)
fix(ec2): merge a launch template with request-level parameters (#453) (
fix(iam): decode query-protocol list parameters (#639) (#640)