diff --git a/lix/legacy/nix-store.cc b/lix/legacy/nix-store.cc index 515b7fae0..57545c3ae 100644 --- a/lix/legacy/nix-store.cc +++ b/lix/legacy/nix-store.cc @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -88,6 +89,16 @@ try { if (i == drv.outputs.end()) throw Error("derivation '%s' does not have an output named '%s'", store2->printStorePath(path.path), j); + if (!outputPaths.contains(i->first)) { + throw Error( + "Possible SQLite database corruption: derivation '%s' output map contains only " + "outputs '{%s}', not '%s'\n" + "Note: derivation output maps are stored in the SQLite database.", + store2->printStorePath(path.path), + concatStringsSep(", ", std::views::keys(outputPaths)), + i->first + ); + } auto outPath = outputPaths.at(i->first); auto retPath = store->printStorePath(outPath); if (store2) {