fix: don't mutate shared matrix AST when resolving ref: rows (#2894)

Co-authored-by: Valentin Maerten <maerten.valentin@gmail.com>
This commit is contained in:
Amit Mishra
2026-06-29 01:33:11 +05:30
committed by GitHub
parent b9b50ca79c
commit 1a0f146888
3 changed files with 88 additions and 6 deletions

View File

@@ -93,6 +93,21 @@ func (matrix *Matrix) DeepCopy() *Matrix {
}
}
// DeepCopy returns a copy of the MatrixRow. Without this, deepcopy.OrderedMap
// falls back to copying the *MatrixRow pointer as-is, so every "copy" of a
// Matrix would still share the same underlying rows - see #2890, where
// concurrent invocations of a task with a `ref:` matrix row raced on
// resolveMatrixRefs mutating that shared row.
func (row *MatrixRow) DeepCopy() *MatrixRow {
if row == nil {
return nil
}
return &MatrixRow{
Ref: row.Ref,
Value: deepcopy.Slice(row.Value),
}
}
func (matrix *Matrix) UnmarshalYAML(node *yaml.Node) error {
switch node.Kind {
case yaml.MappingNode: