diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2023-09-07 11:07:02 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-07 11:07:02 -0400 |
commit | 37d6fff113501f9230178215ea61192cd6e4f9f1 (patch) | |
tree | 4db2cc7ec7969b43f280e23c9a5fc43ea8d55c47 | |
parent | 3a62651bd663a849a568bf69017d0f3b1addd564 (diff) | |
parent | b7edc2099fffd7d54638122d2d9950e3d3a751f6 (diff) |
Merge pull request #8938 from obsidiansystems/better-drv-parsing
Improve derivation parsing
-rw-r--r-- | src/libstore/derivations.cc | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/libstore/derivations.cc b/src/libstore/derivations.cc index dc32c3847..43d3dc4a2 100644 --- a/src/libstore/derivations.cc +++ b/src/libstore/derivations.cc @@ -154,8 +154,9 @@ static void expect(std::istream & str, std::string_view s) { char s2[s.size()]; str.read(s2, s.size()); - if (std::string(s2, s.size()) != s) - throw FormatError("expected string '%1%'", s); + std::string_view s2View { s2, s.size() }; + if (s2View != s) + throw FormatError("expected string '%s', got '%s'", s, s2View); } @@ -223,7 +224,8 @@ static DerivationOutput parseDerivationOutput(const Store & store, const auto hashType = parseHashType(hashAlgo); if (hashS == "impure") { experimentalFeatureSettings.require(Xp::ImpureDerivations); - assert(pathS == ""); + if (pathS != "") + throw FormatError("impure derivation output should not specify output path"); return DerivationOutput::Impure { .method = std::move(method), .hashType = std::move(hashType), @@ -239,7 +241,8 @@ static DerivationOutput parseDerivationOutput(const Store & store, }; } else { experimentalFeatureSettings.require(Xp::CaDerivations); - assert(pathS == ""); + if (pathS != "") + throw FormatError("content-addressed derivation output should not specify output path"); return DerivationOutput::CAFloating { .method = std::move(method), .hashType = std::move(hashType), |