config: a partial overlay silently clears omitted fields in map-valued config (drops target_token) #1292

Closed
opened 2026-10-27 13:39:48 +00:00 by sam · 0 comments
Owner

An overlay or dashboard PATCH that changes only ONE field of a map-valued config entry
silently zeroes the fields it omits. For [services.] that means losing the bearer
token, i.e. losing authentication.

REPRODUCED (measured, not inferred). internal/config/services.go is now
"type Services map[string]ServiceConnection". Through ApplyOverlayValues:

start Services{"state": {Target: "127.0.0.1:50051", TargetToken: "secret"}}
overlay {"services": {"state": {"target": "10.0.0.5:50051"}}}
result Services{"state": {Target: "10.0.0.5:50051", TargetToken: ""}} <-- token CLEARED

and the symmetric case clears Target:

start Services{"state": {Target: "10.0.0.5:50051", TargetToken: "old"}}
overlay {"services": {"state": {"target_token": "rotated"}}}
result Services{"state": {Target: "", TargetToken: "rotated"}}

CAUSE. ApplyOverlayValues does yaml.Marshal(overrides) then yaml.Unmarshal(data, cfg).
yaml.v3 replaces a map VALUE wholesale, so the entry is decoded from scratch and the
omitted fields are zeroed. Its own doc comment promises the opposite: "only the keys
present are replaced, every field the overlay omits keeps its existing value". Before
Services became a map this worked, because a struct field decode is field-wise: the
struct form did not have this bug, the map form does.

IMPACT. Changing a State Store endpoint through an overlay or a dashboard PATCH
silently removes target_token. A non-loopback target then fails closed, so the visible
symptom is a confusing connection failure; a loopback target just loses the token.
The same mechanism applies to EVERY map[string]struct config field -- image.hosted,
image.local, providers, model_limits, extra -- so the fix belongs in ApplyOverlayValues,
not at each field's consumer.

WHY IT WENT UNNOTICED

  • The regression test that would have caught it (TestApplyOverlayValuesPreservesOmittedNestedFields,
    added by PR #879) was written against the STRUCT form and passed. The map landed in a
    different file (services.go, with #878), so git merged cleanly and the test then failed to
    compile against the new type.
  • There is no Go build or test CI: .github/workflows contains only deploy.yml and docs.yml.
    Nothing compiled or tested PR #878 before it merged, so main was left not building.

FIX IN FLIGHT: the producer fix is being implemented red-first against the converted test.

Close reason

Verified complete on origin/main: tests green


Imported from beads archie-core-e2e2 · GitHub #910 · type bug · priority P1 · created 2026-09-18 · closed 2026-09-18

An overlay or dashboard PATCH that changes only ONE field of a map-valued config entry silently zeroes the fields it omits. For [services.<name>] that means losing the bearer token, i.e. losing authentication. REPRODUCED (measured, not inferred). internal/config/services.go is now "type Services map[string]ServiceConnection". Through ApplyOverlayValues: start Services{"state": {Target: "127.0.0.1:50051", TargetToken: "secret"}} overlay {"services": {"state": {"target": "10.0.0.5:50051"}}} result Services{"state": {Target: "10.0.0.5:50051", TargetToken: ""}} <-- token CLEARED and the symmetric case clears Target: start Services{"state": {Target: "10.0.0.5:50051", TargetToken: "old"}} overlay {"services": {"state": {"target_token": "rotated"}}} result Services{"state": {Target: "", TargetToken: "rotated"}} CAUSE. ApplyOverlayValues does yaml.Marshal(overrides) then yaml.Unmarshal(data, cfg). yaml.v3 replaces a map VALUE wholesale, so the entry is decoded from scratch and the omitted fields are zeroed. Its own doc comment promises the opposite: "only the keys present are replaced, every field the overlay omits keeps its existing value". Before Services became a map this worked, because a struct field decode is field-wise: the struct form did not have this bug, the map form does. IMPACT. Changing a State Store endpoint through an overlay or a dashboard PATCH silently removes target_token. A non-loopback target then fails closed, so the visible symptom is a confusing connection failure; a loopback target just loses the token. The same mechanism applies to EVERY map[string]struct config field -- image.hosted, image.local, providers, model_limits, extra -- so the fix belongs in ApplyOverlayValues, not at each field's consumer. WHY IT WENT UNNOTICED - The regression test that would have caught it (TestApplyOverlayValuesPreservesOmittedNestedFields, added by PR #879) was written against the STRUCT form and passed. The map landed in a different file (services.go, with #878), so git merged cleanly and the test then failed to compile against the new type. - There is no Go build or test CI: .github/workflows contains only deploy.yml and docs.yml. Nothing compiled or tested PR #878 before it merged, so main was left not building. FIX IN FLIGHT: the producer fix is being implemented red-first against the converted test. ### Close reason Verified complete on origin/main: tests green --- _Imported from beads `archie-core-e2e2` · GitHub #910 · type bug · priority P1 · created 2026-09-18 · closed 2026-09-18_
sam added the highbug labels 2026-10-27 13:39:48 +00:00
sam self-assigned this 2026-10-27 13:39:48 +00:00
sam closed this issue 2026-10-27 13:39:48 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sam/archie#1292