Skip to content

Commit 06db3de

Browse files
Matovidloclaude
andcommitted
fix(templates): clarify Config.ParentKey fallback safety assumption
Relations.ParentKey can only error here with "multiple parents" — individual relation errors require a non-ConfigKey source which c.Key() never is. Document this so the error suppression is explicit. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 92e7ef5 commit 06db3de

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

internal/pkg/model/object.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -595,15 +595,16 @@ func (r *ConfigRow) GetContent() *orderedmap.OrderedMap {
595595
}
596596

597597
// ParentKey - config parent can be modified via Relations, e.g. variables config embedded in another config.
598-
// When multiple relation-defined parents exist (shared variables config), fall back to the structural
599-
// parent (branch). The two-pass validator emits a warning and the ignore mapper excludes the config;
600-
// this fallback prevents PathsGenerator from crashing if those steps fail to catch every edge case.
598+
// When Relations.ParentKey returns an error it means multiple relation-defined parents exist (a variables
599+
// config shared by more than one consumer). In that case fall back to the structural parent (branch).
600+
// Other error kinds from Relations.ParentKey cannot occur here because individual relation errors require
601+
// a non-ConfigKey source, but c.Key() is always a ConfigKey.
601602
func (c *Config) ParentKey() (Key, error) {
602603
parentKey, err := c.Relations.ParentKey(c.Key())
603604
if err == nil && parentKey != nil {
604605
return parentKey, nil
605606
}
606-
// No parent defined via "Relations" (or multiple parents — fall back to structural parent).
607+
// No parent defined via "Relations", or multiple parents — fall back to structural parent (branch).
607608
return c.ConfigKey.ParentKey()
608609
}
609610

0 commit comments

Comments
 (0)