From 795d7bb5916ebff17b417c82bbb7ef059325d3cb Mon Sep 17 00:00:00 2001 From: Bernardo Meurer Costa Date: Wed, 1 Oct 2025 21:20:33 +0000 Subject: [PATCH] fix(libstore/build/derivation-goal): don't assert on partially valid outputs Fixes: #14130 (cherry picked from commit 9eecee3d4e28634ef11d0044bb2e84bd8b13f2c7) --- src/libstore/build/derivation-goal.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/libstore/build/derivation-goal.cc b/src/libstore/build/derivation-goal.cc index 4b4450bc8..1c485be15 100644 --- a/src/libstore/build/derivation-goal.cc +++ b/src/libstore/build/derivation-goal.cc @@ -182,8 +182,16 @@ Goal::Co DerivationGoal::haveDerivation() } } - if (buildResult.success()) - assert(buildResult.builtOutputs.count(wantedOutput) > 0); + if (buildResult.success()) { + /* If the wanted output is not in builtOutputs (e.g., because it + was already valid and therefore not re-registered), we need to + add it ourselves to ensure we return the correct information. */ + if (buildResult.builtOutputs.count(wantedOutput) == 0) { + debug( + "BUG! wanted output '%s' not in builtOutputs, working around by adding it manually", wantedOutput); + buildResult.builtOutputs = {{wantedOutput, assertPathValidity()}}; + } + } } co_return amDone(g->exitCode, g->ex);