Context
Found while implementing #494 (spawn resume --max-concurrent-auto), which needs a reliably-set region — this bug sits directly upstream of that.
cmd/resume.go's region-resolution logic:
region := ""
for _, inst := range state.Instances {
if inst.InstanceID != "" {
region = paramFormat.Defaults["region"].(string)
break
}
}
if region == "" {
region = "us-east-1" // Default
}
The bug
paramFormat.Defaults["region"].(string) is an unchecked (non-, ok) type assertion. If the sweep's original parameter file has no top-level region in defaults (e.g. every param set set its own region individually, or the sweep only ever used the CLI's --region flag rather than a param-file default), Defaults["region"] is nil, and nil.(string) panics rather than falling through to the region == "" → "us-east-1" fallback below it.
The panic is reachable only when state.Instances has at least one entry with a non-empty InstanceID (i.e. at least one instance was actually launched before the sweep was interrupted) AND the param file's defaults map has no region key or a non-string one — otherwise the loop body never runs and the region == "" fallback below correctly applies.
Ask
Use the checked form (region, _ = paramFormat.Defaults["region"].(string)), or better, derive region the same way the rest of the per-config logic already does (buildLaunchConfigFromParams's per-entry region, falling back through defaults) rather than reaching into Defaults directly and assuming a top-level scalar. Worth checking whether state.Instances[i]'s own recorded config/tags could just carry the region it actually used, removing the guesswork entirely.
Not filed as blocking anything — spawn resume's existing --max-concurrent path has lived with this since before #492/#494; flagging it now because #494's --max-concurrent-auto makes correctness of region matter more (a wrong/panicked region means a wrong quota answer, not just a wrong ListInstances region filter).
Context
Found while implementing #494 (
spawn resume --max-concurrent-auto), which needs a reliably-setregion— this bug sits directly upstream of that.cmd/resume.go's region-resolution logic:The bug
paramFormat.Defaults["region"].(string)is an unchecked (non-, ok) type assertion. If the sweep's original parameter file has no top-levelregionindefaults(e.g. every param set set its ownregionindividually, or the sweep only ever used the CLI's--regionflag rather than a param-file default),Defaults["region"]isnil, andnil.(string)panics rather than falling through to theregion == ""→"us-east-1"fallback below it.The panic is reachable only when
state.Instanceshas at least one entry with a non-emptyInstanceID(i.e. at least one instance was actually launched before the sweep was interrupted) AND the param file'sdefaultsmap has noregionkey or a non-string one — otherwise the loop body never runs and theregion == ""fallback below correctly applies.Ask
Use the checked form (
region, _ = paramFormat.Defaults["region"].(string)), or better, derive region the same way the rest of the per-config logic already does (buildLaunchConfigFromParams's per-entry region, falling back through defaults) rather than reaching intoDefaultsdirectly and assuming a top-level scalar. Worth checking whetherstate.Instances[i]'s own recorded config/tags could just carry the region it actually used, removing the guesswork entirely.Not filed as blocking anything —
spawn resume's existing--max-concurrentpath has lived with this since before #492/#494; flagging it now because #494's--max-concurrent-automakes correctness ofregionmatter more (a wrong/panicked region means a wrong quota answer, not just a wrongListInstancesregion filter).