From f566957dc4a827ec5b5ee24f5f37aaa5183a95d7 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 | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/libstore/build/derivation-goal.cc b/src/libstore/build/derivation-goal.cc index 2e57c1708..cd4a2df6f 100644 --- a/src/libstore/build/derivation-goal.cc +++ b/src/libstore/build/derivation-goal.cc @@ -182,7 +182,19 @@ Goal::Co DerivationGoal::haveDerivation() } } - assert(success.builtOutputs.count(wantedOutput) > 0); + /* 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 (success.builtOutputs.count(wantedOutput) == 0) { + debug( + "BUG! wanted output '%s' not in builtOutputs, working around by adding it manually", wantedOutput); + auto realisation = assertPathValidity(); + realisation.id = DrvOutput{ + .drvHash = outputHash, + .outputName = wantedOutput, + }; + success.builtOutputs.emplace(wantedOutput, std::move(realisation)); + } } }