From 1d4baca0d94580b56ff0d736f6a7548109bfba7a Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Thu, 14 Oct 2021 17:45:42 -0400 Subject: [PATCH] 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. --- src/Context.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Context.cpp b/src/Context.cpp index 37daa97b4..565d6abc3 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -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;