From 778656381c8c05d88453140612b4053dbc2ce787 Mon Sep 17 00:00:00 2001 From: Oliver Reiche Date: Tue, 6 May 2025 10:50:09 +0200 Subject: Executor: Verify types of output artifacts ... as Justbuild has a strict separation between output files and output directories, but the RBE protocol does not necessarily maintain such a separation and therefore does not perform such a verification. --- .../execution_engine/executor/executor.hpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/buildtool/execution_engine/executor/executor.hpp b/src/buildtool/execution_engine/executor/executor.hpp index 5f5c2e92..85d01732 100644 --- a/src/buildtool/execution_engine/executor/executor.hpp +++ b/src/buildtool/execution_engine/executor/executor.hpp @@ -643,7 +643,8 @@ class ExecutorImpl { return api.UploadTree(artifacts); } /// \brief Check that all outputs expected from the action description - /// are present in the artifacts map + /// are present in the artifacts map and of the expected type + template [[nodiscard]] static auto CheckOutputsExist( IExecutionResponse::ArtifactInfos const& artifacts, std::vector const& outputs, @@ -652,8 +653,18 @@ class ExecutorImpl { outputs.begin(), outputs.end(), [&artifacts, &base](Action::LocalPath const& output) { - return artifacts.contains( - RebasePathStringRelativeTo(base, output)); + auto it = + artifacts.find(RebasePathStringRelativeTo(base, output)); + if (it != artifacts.end()) { + auto const& type = it->second.type; + if constexpr (kIsTree) { + return IsTreeObject(type) or IsSymlinkObject(type); + } + else { + return IsFileObject(type) or IsSymlinkObject(type); + } + } + return false; }); } @@ -715,9 +726,9 @@ class ExecutorImpl { std::sort(output_dirs.begin(), output_dirs.end()); if (artifacts.value()->empty() or - not CheckOutputsExist( + not CheckOutputsExist( *artifacts.value(), output_files, action->Content().Cwd()) or - not CheckOutputsExist( + not CheckOutputsExist( *artifacts.value(), output_dirs, action->Content().Cwd())) { logger.Emit(LogLevel::Error, [&]() { std::ostringstream message{}; -- cgit v1.2.3