Skip to content

Skip database tables with no export files#1210

Open
rlillyrfy wants to merge 2 commits into
microsoft:mainfrom
rlillyrfy:fix-skip-empty-exports
Open

Skip database tables with no export files#1210
rlillyrfy wants to merge 2 commits into
microsoft:mainfrom
rlillyrfy:fix-skip-empty-exports

Conversation

@rlillyrfy
Copy link
Copy Markdown

Description

Fixes a crash in New-EntraTable when processing exports with no matching files.

When Graph API role restrictions prevent certain exports (e.g., User, ServicePrincipalSignIn), the table creation step fails with "No files found that match the pattern" because DuckDB cannot create a table from an empty file set.

Changes

  • Added an early guard in New-EntraTable to skip table creation when no export JSON files match the expected pattern
  • Allows the assessment to continue past role-restricted exports instead of aborting

Testing

  • Validated by re-running the assessment with restricted permissions; the export step now gracefully skips missing files instead of crashing during database creation

Copilot AI review requested due to automatic review settings May 9, 2026 21:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prevents DuckDB table creation from crashing when an export produces no matching JSON files (commonly due to Graph permission/role restrictions), allowing the database-build phase to continue instead of aborting.

Changes:

  • Added a pre-check in New-EntraTable to detect when $FilePath matches zero files.
  • Logs a warning and skips table creation when no matching export files are found.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/powershell/private/db/content/New-EntraTable.ps1 Outdated
Comment on lines +26 to +29
if (-not $matchingFiles) {
Write-PSFMessage "Skipping table $TableName because no files matched the pattern $FilePath" -Level Warning -Tag DB
return
}
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 9, 2026 21:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment on lines +25 to +29
$matchingFiles = Get-ChildItem -Path $FilePath -File -ErrorAction SilentlyContinue | Select-Object -First 1
if (-not $matchingFiles) {
Write-PSFMessage "Skipping table $TableName because no files matched the pattern $FilePath" -Level Warning -Tag DB
return
}
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

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.

2 participants