context: Do not interpret empty filter/mods as missing context definition

This is a corner case bug, when user has both old-style and new-style
context defined, where new-style is defined as empty string, the
old-style will (incorrectly) take precedence.

Closes #2629.
This commit is contained in:
Tomas Babej 2021-10-14 17:45:42 -04:00
parent 887b04f7f4
commit 1d4baca0d9
No known key found for this signature in database
GPG key ID: B0747C6578F7D2F5

View file

@ -966,8 +966,9 @@ std::string Context::getTaskContext (const std::string& kind, std::string name,
}
// Figure out the context string for this kind (read/write)
std::string contextString = config.get ("context." + name + "." + kind);
if (contextString.empty ())
std::string contextString;
if (! config.has ("context." + name + "." + kind))
{
debug ("Specific " + kind + " context for '" + name + "' not defined. ");
if (fallback)
@ -976,6 +977,8 @@ std::string Context::getTaskContext (const std::string& kind, std::string name,
contextString = config.get ("context." + name);
}
}
else
contextString = config.get ("context." + name + "." + kind);
debug (format ("Detected context string: {1}", contextString.empty() ? "(empty)" : contextString));
return contextString;