Skip to content

Commit

Permalink
Merge pull request #8938 from obsidiansystems/better-drv-parsing
Browse files Browse the repository at this point in the history
Improve derivation parsing
  • Loading branch information
Ericson2314 authored Sep 7, 2023
2 parents 3a62651 + b7edc20 commit 37d6fff
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/libstore/derivations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand Down Expand Up @@ -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),
Expand All @@ -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),
Expand Down

0 comments on commit 37d6fff

Please sign in to comment.