Skip to content

A detached parameter sweep launches ZERO instances and reports success (MissingParameter: ImageId) #749

Closed

Description

@scttfrdmn

Found by running the real-hardware test for #725. More serious than #725
itself
, and it changes that issue's premise.

What happens

A plain two-row sweep, no --ami, on the default path (detached is
auto-enabled for parameter sweeps):

$ spawn launch s725 --instance-type t4g.small --region us-east-1 \
    --param-file rows.json --command 'sleep 1200' --ttl 20m --cost-limit 0.50
🚀 Invoking Lambda orchestrator...
✓ Lambda invoked
✅ Parameter sweep queued successfully!
Sweep ID: sweep-20261007-033000
...
The sweep is now running in Lambda. You can disconnect safely.

Exit 0. The orchestrator's own log for that sweep:

Launching 2 instances (slots available: 2)
Trying instance type t4g.small for param 0
Failed to launch instance 0: run instances failed: ... api error MissingParameter:
  The request must contain the parameter ImageId
Trying instance type t4g.small for param 1
Failed to launch instance 1: run instances failed: ... api error MissingParameter:
  The request must contain the parameter ImageId
All instances launched and completed

Zero instances. aws ec2 describe-instances in the target account returns
nothing. And the Lambda logs All instances launched and completed immediately
after two hard failures, so the CLI's "queued successfully" is never contradicted.

Root cause: the CLI and the Lambda disagree on the key set

The orchestrator builds RunInstancesInput from param keys
(lambda/sweep-orchestrator/main.go:715-718):

ami      := getStringParam(config, "ami", "")
keyName  := getStringParam(config, "key_name", "")
iamRole  := getStringParam(config, "iam_role", "spawnd-role")
spot     := getBoolParam(config, "spot", false)

and sets input.ImageId only if ami != "". Diffing what it reads against
what the CLI writes into defaults:

keys
orchestrator reads ami iam_role instance_type key_name spot ttl
CLI seeds cost_limit iam_role idle_timeout instance_type region ttl volume_size
missing, required ami → no ImageId → every RunInstances rejected
missing, silent key_name (no SSH key), spot (--spot never honoured)

The actual params.json the CLI uploaded for the run above:

{"defaults": {"cost_limit": 0.5, "instance_type": "t4g.small",
              "region": "us-east-1", "ttl": "20m"},
 "params": [{"trial": "a"}, {"trial": "b"}]}

No ami. So this is #697's class again, on the Lambda path — flags that
reach a LaunchConfig the Lambda never sees. #697 fixed the foreground sweep and
explicitly scoped itself out of the detached one; this is the part that was left.

A detached sweep therefore works only if the param file spells out ami:
itself. --ami on the command line is dropped. That is consistent with #725's
reporter having seen real rows with spawn:sweep-id tags: their param file must
have carried an AMI.

Not a regression from the recent redeploy

I redeployed this Lambda earlier today (first update since 2026-01-17), so I
checked: git log --follow -S'getStringParam(config, "ami"' shows the AMI
handling unchanged since the initial commit, and the only other commit to the
file is #726's tag addition. The deployed binary is also byte-identical to a
local rebuild of main. This has never worked without an explicit ami: in the
file.

What it means for #725

#725 said detached rows carry no spawn:managed tag and so can be stopped by
nothing. The tag fix (#726) is correct, but unobservable on the default path,
because the default path creates nothing to tag. The ordering is now: this issue
first, then #725's tagging becomes verifiable.

It also revises an earlier diagnosis of mine. The hardware smoke's sweep leg
reported sweep INCONCLUSIVE: expected 2 running rows, found 0, and I attributed
that to checking before the Lambda had launched anything. That was wrong — or at
best half right. The rows never existed. "Found 0" was a true positive about
a total failure, and I explained it away as a timing artifact.

Suggested fix

  1. Seed every key the Lambda reads. The CLI already has the mechanism
    (cmd/launch_sweep.go writes instance_type/region/etc. into Defaults);
    add ami, key_name and spot. For ami, the resolved value — the CLI
    auto-detects the latest AL2023 when --ami is absent, and that resolution must
    happen before the upload, not be left to a Lambda that cannot do it.
  2. Make the key set a gate, not a convention. The orchestrator and the CLI
    should agree by construction — a shared list of param keys, or a test that
    greps getStringParam/getBoolParam in the Lambda and asserts the CLI seeds
    each one. A silent "" default is what turned a missing key into a 400 from
    EC2 and then into a success message.
  3. Stop reporting success after failing. All instances launched and completed must not be logged when zero of N launched, and a sweep whose rows
    all failed must be recorded as failed in the sweep table so
    spawn status --sweep-id says so. Right now the only evidence is the Lambda's
    own log.
  4. Have the CLI verify, or stop promising. "The sweep is now running in
    Lambda. You can disconnect safely" is a claim the CLI cannot currently support.
    Either poll briefly for the first row, or soften the message and point at
    spawn status --sweep-id.

(3) is arguably the worst of the four: a cost-control tool reporting a launch
that did not happen is the same failure class as #737, where a declined terminate
exited 0.

Cost note

Nothing leaked — zero instances were created, which is the one silver lining. The
test's own cleanup and an independent describe-instances both confirm 0 live
instances in the target account.

Environment: spawn built from main at 45815b3, spawn-sweep-orchestrator
deployed 2026-10-08 (CodeSha256 verified against a local rebuild), us-east-1,
target account 435415984226.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions