diff --git a/agents/scripts/build/main.go b/agents/scripts/build/main.go index 348a4055..38c7cce5 100644 --- a/agents/scripts/build/main.go +++ b/agents/scripts/build/main.go @@ -1060,6 +1060,10 @@ func (ab *AppBuilder) autoDetectExtensions() error { return err } + // Ensure that all extension modules are unique, otherwise the modules with + // same name will be overwritten. + uniqueModules := make(map[string]string) + for _, entry := range entries { if !entry.IsDir() { continue @@ -1076,6 +1080,16 @@ func (ab *AppBuilder) autoDetectExtensions() error { continue } + if location, ok := uniqueModules[ext.module]; ok { + return fmt.Errorf( + "the extensions [%s] and [%s] have duplicated module name [%s]", + path.Base(location), + path.Base(ext.location), + ext.module, + ) + } + + uniqueModules[ext.module] = ext.location ab.extensions = append(ab.extensions, ext) } diff --git a/agents/scripts/install_deps_and_build.sh b/agents/scripts/install_deps_and_build.sh index 43e3a6b4..07645ee1 100755 --- a/agents/scripts/install_deps_and_build.sh +++ b/agents/scripts/install_deps_and_build.sh @@ -65,6 +65,10 @@ build_go_app() { cd $app_dir go run scripts/build/main.go --verbose + if [[ $? -ne 0 ]]; then + echo "FATAL: failed to build go app, see logs for detail." + exit 1 + fi } clean() {