Repository navigation
Description
Severity: medium — the same "unrecognised input accepted in silence" pattern as #526, one level up
pkg/params.ParamFileFormat has exactly three fields — defaults, grid, params — and both
parsers unmarshal into it without KnownFields/DisallowUnknownFields:
pkg/params/parser.go:54-57(JSON):json.Unmarshal(data, &format)pkg/params/parser.go:72-75(YAML):yaml.Unmarshal(data, &format)
So any other top-level key is discarded before validation ever sees it. Not passed through as a
PARAM_* (that at least leaves a tag you could find) — discarded.
This is not hypothetical. Two of spawn's own shipped examples are written that way:
examples/simple-params.yaml puts region:/instance_type:/ami: at the top level.
examples/schedule-params.yaml puts sweep_name:, region:, max_concurrent:,
launch_delay:, instance_type:, ami: and disk_size: at the top level — and
cmd/schedule.go:542-560 reads sweep_name, max_concurrent and launch_delay out of
defaults:, not the top level:
func (p *parsedParams) getSweepName() string {
if name, ok := p.defaults["sweep_name"].(string); ok {
return name
}
return "sweep"
}So a user who copies schedule-params.yaml gets sweep, 10, and 10s — the defaults — with
no indication that the file they wrote was ignored.
Why it matters more than "the example is wrong"
ttl:, idle_timeout: and cost_limit: at the top level are the dangerous form. A user who
writes
ttl: 2h
params:
- instance_type: c7g.16xlargehas written a bound, had it silently dropped, and gets an unbounded instance. #526 covers the
same mistake made inside defaults:/params: (where it at least becomes a visible
spawn:param:* tag); at the top level there is no trace at all.
Expected behaviour
Unknown top-level keys should not be silently discarded. Suggested split, because a blanket
error is breaking:
- Error when a top-level key is a recognised row key — the misplacement is unambiguous and
the lifecycle/spend ones cost money. Message: "ttl:at the top level is ignored; move it
underdefaults:to apply it to every row." - Warn for anything else, naming the keys and saying they are ignored — that covers
description:,version:and other metadata people reasonably add, without breaking files
that already carry them. - Fix
examples/simple-params.yamlandexamples/schedule-params.yamlin the same change, or
the first thing the new check fires on is spawn's own documentation.
Note spawn schedule uses its own parseParamsFile (cmd/schedule.go:521) rather than
pkg/params, so a fix in pkg/params will not cover the schedule path — and the schedule path
legitimately reads sweep-level settings from defaults:, which the launch path treats as
per-row. That divergence is worth a look on its own.
Regression test to add
A param file with ttl: 2h at the top level and one unbounded row must fail (or, if only
warned, must still not report a bound it does not have) — and the test must assert nothing
launched via the instance inventory, not just a non-zero exit.
Found while fixing #526. Related: #524, #525, #526 — all four are "spawn accepted input that
did nothing, and said nothing about it" on the sweep launch path.
Activity
fix: reject or warn on top-level param-file keys outside defaults:/gr…
fix: reject or warn on top-level param-file keys outside defaults:/gr…