Skip to content

Commit 2a23559

Browse files
committed
Extractor: fall back to full extraction on overlay changes json read error
1 parent 5328643 commit 2a23559

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

python/extractor/semmle/traverser.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,16 @@ def __init__(self, options, modulenames, logger):
3434
# During overlay extraction, only traverse the files that were changed.
3535
self.overlay_changes = None
3636
if 'CODEQL_EXTRACTOR_PYTHON_OVERLAY_CHANGES' in os.environ:
37-
with open(os.environ['CODEQL_EXTRACTOR_PYTHON_OVERLAY_CHANGES'], 'r', encoding='utf-8') as f:
38-
data = json.load(f)
39-
changed_paths = data.get('changes', [])
40-
self.overlay_changes = { os.path.abspath(p) for p in changed_paths }
37+
overlay_changes_file = os.environ['CODEQL_EXTRACTOR_PYTHON_OVERLAY_CHANGES']
38+
logger.info("Overlay extraction mode: only extracting files changed according to '%s'", overlay_changes_file)
39+
try:
40+
with open(overlay_changes_file, 'r', encoding='utf-8') as f:
41+
data = json.load(f)
42+
changed_paths = data.get('changes', [])
43+
self.overlay_changes = { os.path.abspath(p) for p in changed_paths }
44+
except (IOError, ValueError) as e:
45+
logger.warn("Failed to read overlay changes from '%s' (falling back to full extraction): %s", overlay_changes_file, e)
46+
self.overlay_changes = None
4147
self.exclude_paths = set([ os.path.abspath(f) for f in options.exclude_file ])
4248
self.exclude = exclude_filter_from_options(options)
4349
self.filter = filter_from_options_and_environment(options)

0 commit comments

Comments
 (0)