Agent: strict config unmarshal + schema version check — reject configs with unknown fields #9
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem. The rendered-config types in
internal/agentare definedindependently of the API's compiler output, and the payload carries no schema
version. If the API emits a section or field an older agent doesn't know about,
Go's default YAML/JSON unmarshal silently drops it. The agent then applies a
partial policy and reports the generation as fully applied — the convergence
view shows green while the device is missing rules.
Proposal.
yaml.KnownFields(true)/DisallowUnknownFields); anyunknown field is a hard error, not a skip.
schema_versionto the rendered config. Agent refuses toapply a version newer than it understands and reports
status: incompatible-schemainstead of a generation number.don't-fail-closed behaviour) so an incompatible push degrades to "stale",
never to "silently partial".
Acceptance. An agent one release behind, fed a config with a new section:
does not apply, does not report the new generation, alerts via status. Unit
test with an unknown top-level key and an unknown nested field.
Related: shared types module issue in tomswallapi (#7 below) removes the drift
source; this issue is the defense when drift happens anyway.