You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: improve test coverage and docs for shared-variables guard
- Extend TestRelationsMapperVariablesSharedAcrossConsumers with a values
row loaded after both consumers, exercising the > 1 guard in
VariablesValuesForRelation.NewOtherSideRelation
- Replace fragile strings.Count(WarnAndErrorMessages, "variablesFor")
assertion with AllMessagesTxt check for the exact formatted message
- Fix grammar: "create" → "creates" in linkRelations comment
- Document the > 1 guard mechanism and the remaining edge case where
values_row is iterated before consumers in docs/relations-validation.md
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/relations-validation.md
+7-1Lines changed: 7 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,7 +65,13 @@ A values row's `variablesValuesFor` relation is linked by looking up the parent
65
65
66
66
Calling `GetOneByType(VariablesForRelType)` on Y at this point returns an error ("only one expected, but found 2"). If that error were propagated, it would produce a duplicate "invalid config Y" message alongside the one already generated by Pass 2 validation of Y itself.
67
67
68
-
To avoid the duplicate, `NewOtherSideRelation` silently returns `(nil, nil, nil)` when `GetOneByType` reports multiple relations — deferring to Pass 2 to emit the canonical warning. The `variablesValuesFor` relation on the values row is left in place; the values row is then transitively excluded from the pull output by the ignore mapper (see below).
68
+
To avoid the duplicate, `NewOtherSideRelation` checks `len(GetByType(VariablesForRelType)) > 1` before calling `GetOneByType`. When multiple relations exist, it returns `(nil, nil, nil)` — deferring to Pass 2 to emit the canonical warning. The `variablesValuesFor` relation on the values row is left in place; the values row is then transitively excluded from the pull output by the ignore mapper (see below).
69
+
70
+
### Edge case: values row iterated before consumers
71
+
72
+
If the Loaded() order is `vars_config → values_row → consumer1 → consumer2`, then when `linkRelations(values_row)` runs in Pass 1, Y has zero `variablesFor` entries (consumers have not been processed yet). The `> 1` guard does not fire. `GetOneByType` returns `nil` (no relation found), and `NewOtherSideRelation` returns the "missing relation variablesFor" error — producing an extra warning in the output alongside the "found 2" warning from Pass 2.
73
+
74
+
This double-warning is a pre-existing edge case. In practice it does not arise because consumer configs always appear in Loaded() before variables values rows (the Storage API returns consumers, and values rows are discovered via the consumer's `variablesValuesFrom` relations). The `> 1` guard eliminates the more common ordering issue; the remaining edge case is benign — both warnings correctly describe the malformed setup.
69
75
70
76
## Why the ignore mapper excludes orphaned variables configs
0 commit comments