Skip to content

Fix AttributeError when a File entity has no name or friendlyName - #233

Draft
briandelmsft with Copilot wants to merge 3 commits into
mainfrom
copilot/stat-232-fix-attribute-error
Draft

Fix AttributeError when a File entity has no name or friendlyName#233
briandelmsft with Copilot wants to merge 3 commits into
mainfrom
copilot/stat-232-fix-attribute-error

Conversation

Copilot AI commented Aug 21, 2026

Copy link
Copy Markdown

Sentinel can attach File entities with empty properties, e.g.:

{ "kind": "File", "name": "61127ee5-...", "type": "Microsoft.SecurityInsights/Entities", "properties": {} }

enrich_files assumed a name was always present, so file_field was None and the base module failed with AttributeError: 'NoneType' object has no attribute 'split'.

Changes (modules/base.py)

  • Skip nameless file entities: when neither properties.friendlyName nor Name resolves, the entity is skipped, following the same pattern already used for unparseable IP entities in enrich_ips.
  • Count after enrichment: FilesCount is now derived from len(base_object.Files) after the loop (previously len(file_entities)), so it stays consistent with the enriched list once entities can be skipped — matching IPsCount.
file_field = data.coalesce(file.get('properties',{}).get('friendlyName'), file.get('Name'))

if not file_field:
    #Skip any file entities that have no file name
    continue

Tests

  • tests/test_stat_base.py: added an offline test_enrich_files covering a normal file, an entity with empty properties, and one with a null friendlyName, asserting only the valid entity is enriched and Files/FilesCount agree.

Co-authored-by: briandelmsft <68655382+briandelmsft@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix AttributeError on file entity missing name and friendlyName Fix AttributeError when a File entity has no name or friendlyName Aug 21, 2026
Copilot AI requested a review from briandelmsft August 21, 2026 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AttributeError on file entity missing name and friendlyName

2 participants