From b99b3b8ac373dccce8f16e1d7bfaee613ca51a5e Mon Sep 17 00:00:00 2001
From: Joey Vagedes <joeyvagedes@microsoft.com>
Date: Tue, 12 Sep 2023 08:08:59 -0700
Subject: [PATCH] Skip instanced_fv_table if the FDF is not set

---
 edk2toollib/database/tables/instanced_fv_table.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/edk2toollib/database/tables/instanced_fv_table.py b/edk2toollib/database/tables/instanced_fv_table.py
index 3174e6c7..8d9e5edf 100644
--- a/edk2toollib/database/tables/instanced_fv_table.py
+++ b/edk2toollib/database/tables/instanced_fv_table.py
@@ -7,6 +7,7 @@
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 ##
 """A module to generate a table containing fv information."""
+import logging
 import re
 import sqlite3
 from pathlib import Path
@@ -53,11 +54,15 @@ def parse(self, db_cursor: sqlite3.Cursor, pathobj: Edk2Path, id, env) -> None:
         self.pathobj = pathobj
         self.ws = Path(self.pathobj.WorkspacePath)
         self.env = env
-        self.dsc = self.env["ACTIVE_PLATFORM"]
-        self.fdf = self.env["FLASH_DEFINITION"]
+        self.dsc = self.env.get("ACTIVE_PLATFORM", None)
+        self.fdf = self.env.get("FLASH_DEFINITION", None)
         self.arch = self.env["TARGET_ARCH"].split(" ")
         self.target = self.env["TARGET"]
 
+        if self.dsc is None or self.fdf is None:
+            logging.debug("DSC or FDF not found in environment. Skipping InstancedFvTable")
+            return
+
         # Our DscParser subclass can now parse components, their scope, and their overrides
         fdfp = FdfP().SetEdk2Path(self.pathobj)
         fdfp.SetInputVars(self.env)