From c9402837503712a1af3b5533dc6a76e3475321c7 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Thu, 14 Aug 2025 00:26:19 -0400 Subject: [PATCH] `DerivationBuilder` Move output result filtering logic and assert just into the branch where it is not obviously a no op / meeting the assertion. Add a comment too, while we are at it. --- src/libstore/build/derivation-goal.cc | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/libstore/build/derivation-goal.cc b/src/libstore/build/derivation-goal.cc index 3db335b04..5407e6f60 100644 --- a/src/libstore/build/derivation-goal.cc +++ b/src/libstore/build/derivation-goal.cc @@ -169,18 +169,21 @@ Goal::Co DerivationGoal::haveDerivation() So we want to make sure the ones that we wanted to check are properly there. */ buildResult.builtOutputs = {{wantedOutput, assertPathValidity()}}; - } - - for (auto it = buildResult.builtOutputs.begin(); it != buildResult.builtOutputs.end();) { - if (it->first != wantedOutput) { - it = buildResult.builtOutputs.erase(it); - } else { - ++it; + } else { + /* Otherwise the builder will give us info for out output, but + also for other outputs. Filter down to just our output so as + not to leak info on unrelated things. */ + for (auto it = buildResult.builtOutputs.begin(); it != buildResult.builtOutputs.end();) { + if (it->first != wantedOutput) { + it = buildResult.builtOutputs.erase(it); + } else { + ++it; + } } - } - if (buildResult.success()) - assert(buildResult.builtOutputs.count(wantedOutput) > 0); + if (buildResult.success()) + assert(buildResult.builtOutputs.count(wantedOutput) > 0); + } co_return amDone(g->exitCode, g->ex); }