diff --git a/k4FWCore/include/k4FWCore/IMetadataSvc.h b/k4FWCore/include/k4FWCore/IMetadataSvc.h index 019af862..8ad64727 100644 --- a/k4FWCore/include/k4FWCore/IMetadataSvc.h +++ b/k4FWCore/include/k4FWCore/IMetadataSvc.h @@ -37,7 +37,13 @@ class IMetadataSvc : virtual public IInterface { getFrame()->putParameter(name, obj); } - template std::optional get(const std::string& name) { return getFrame()->getParameter(name); } + template std::optional get(const std::string& name) { + auto* frame = getFrame(); + if (!frame) { + return std::nullopt; + } + return frame->getParameter(name); + } }; #endif