diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2023-05-09 14:44:08 -0400 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2023-05-09 14:44:08 -0400 |
commit | 6a3a87a714e1f3be1464f8fd4c82714b7d032879 (patch) | |
tree | 4a8a911a6f026578e78bc120869451f5bbe95056 /src/libstore/build/local-derivation-goal.cc | |
parent | e514b3939adb087338a9ef7445afcecb0efb42b1 (diff) |
Improve error message for self reference with text hashing
The `ContentAddressWithReferences` method is made total, with error
handling now squarely the caller's job. This is better.
Diffstat (limited to 'src/libstore/build/local-derivation-goal.cc')
-rw-r--r-- | src/libstore/build/local-derivation-goal.cc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/libstore/build/local-derivation-goal.cc b/src/libstore/build/local-derivation-goal.cc index eb6c00e77..2e4020f33 100644 --- a/src/libstore/build/local-derivation-goal.cc +++ b/src/libstore/build/local-derivation-goal.cc @@ -2456,13 +2456,21 @@ SingleDrvOutputs LocalDerivationGoal::registerOutputs() }, }, outputHash.method.raw); auto got = caSink.finish().first; + + auto optCA = ContentAddressWithReferences::fromPartsOpt( + outputHash.method, + std::move(got), + rewriteRefs()); + if (!optCA) { + // TODO track distinct failure modes separately (at the time of + // writing there is just one but `nullopt` is unclear) so this + // message can't get out of sync. + throw BuildError("output path '%s' has illegal content address, probably a spurious self-reference with text hashing"); + } ValidPathInfo newInfo0 { worker.store, outputPathName(drv->name, outputName), - ContentAddressWithReferences::fromParts( - outputHash.method, - std::move(got), - rewriteRefs()), + *std::move(optCA), Hash::dummy, }; if (*scratchPath != newInfo0.path) { |