mirror of
https://github.com/NixOS/nix
synced 2025-06-24 22:11:15 +02:00
fromStructuredAttrs(): Don't crash if exportReferencesGraph is a string
Fixes
error: [json.exception.type_error.302] type must be array, but is string
and other crashes.
Fixes #13254.
(cherry picked from commit d877b0c0cc
)
This commit is contained in:
parent
acc3cd460d
commit
8ca4d2ef08
2 changed files with 9 additions and 2 deletions
|
@ -211,8 +211,13 @@ DerivationOptions::fromStructuredAttrs(const StringMap & env, const StructuredAt
|
|||
auto e = optionalValueAt(parsed->structuredAttrs, "exportReferencesGraph");
|
||||
if (!e || !e->is_object())
|
||||
return ret;
|
||||
for (auto & [key, storePathsJson] : getObject(*e)) {
|
||||
ret.insert_or_assign(key, storePathsJson);
|
||||
for (auto & [key, value] : getObject(*e)) {
|
||||
if (value.is_array())
|
||||
ret.insert_or_assign(key, value);
|
||||
else if (value.is_string())
|
||||
ret.insert_or_assign(key, StringSet{value});
|
||||
else
|
||||
throw Error("'exportReferencesGraph' value is not an array or a string");
|
||||
}
|
||||
} else {
|
||||
auto s = getOr(env, "exportReferencesGraph", "");
|
||||
|
|
|
@ -225,6 +225,8 @@ void Store::queryMissing(const std::vector<DerivedPath> & targets,
|
|||
auto parsedDrv = StructuredAttrs::tryParse(drv->env);
|
||||
DerivationOptions drvOptions;
|
||||
try {
|
||||
// FIXME: this is a lot of work just to get the value
|
||||
// of `allowSubstitutes`.
|
||||
drvOptions = DerivationOptions::fromStructuredAttrs(
|
||||
drv->env,
|
||||
parsedDrv ? &*parsedDrv : nullptr);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue