From 4f8a887fff7b1780723068e3f410a2d10ea66ec0 Mon Sep 17 00:00:00 2001 From: William Dumont Date: Mon, 29 Apr 2024 17:44:47 +0200 Subject: [PATCH] Backport: nest datapath in parents to prevent collision in nested import git --- CHANGELOG.md | 2 ++ internal/flow/internal/controller/node_config_import.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05de3c37ffc9..ad8f9b53ffed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ Main (unreleased) - Fix a bug where custom components would not shadow the stdlib. If you have a module whose name conflicts with an stdlib function and if you use this exact function in your config, then you will need to rename your module. (@wildum) +- Fix an issue where nested import.git config blocks could conflict if they had the same labels. (@wildum) + ### Other changes - Change the Docker base image for Linux containers to `ubuntu:noble`. (@amontalban) diff --git a/internal/flow/internal/controller/node_config_import.go b/internal/flow/internal/controller/node_config_import.go index e87a1223cc5b..35f7dd409533 100644 --- a/internal/flow/internal/controller/node_config_import.go +++ b/internal/flow/internal/controller/node_config_import.go @@ -286,6 +286,8 @@ func (cn *ImportConfigNode) processImportBlock(stmt *ast.BlockStmt, fullName str childGlobals := cn.globals // Children have a special OnBlockNodeUpdate function which notifies the parent when its content changes. childGlobals.OnBlockNodeUpdate = cn.onChildrenContentUpdate + // Children data paths are nested inside their parents to avoid collisions. + childGlobals.DataPath = filepath.Join(childGlobals.DataPath, cn.globalID) cn.importConfigNodesChildren[stmt.Label] = NewImportConfigNode(stmt, childGlobals, sourceType) return nil }