Skip to content

Fix File I/O NULL fallbacks for restricted permissions (#633)#640

Merged
erikdarlingdata merged 1 commit intodevfrom
fix/file-io-null-masterfiles-633
Mar 19, 2026
Merged

Fix File I/O NULL fallbacks for restricted permissions (#633)#640
erikdarlingdata merged 1 commit intodevfrom
fix/file-io-null-masterfiles-633

Conversation

@erikdarlingdata
Copy link
Owner

@erikdarlingdata erikdarlingdata commented Mar 19, 2026

When sys.master_files is inaccessible, ISNULL now falls back to DB_NAME() and File_{id}.

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced file I/O statistics collection by implementing improved null-value handling and more robust fallback values when critical metadata such as database names, file names, and physical paths are unavailable or missing.
    • Refined data collection expressions to ensure complete and accurate file I/O statistics, preventing incomplete or malformed records in collected metrics.

When the login lacks VIEW ANY DEFINITION, sys.master_files returns
NULLs via the LEFT JOIN. Updated ISNULL fallbacks in both the Lite
collector and the Full Edition install script:

- database_name: falls back to DB_NAME(vfs.database_id)
- file_name: falls back to 'File_{file_id}'
- physical_name: falls back to empty string

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@erikdarlingdata erikdarlingdata merged commit e6515d3 into dev Mar 19, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 19, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1cf9676c-4ae5-4ff8-bc2e-149d526c6c41

📥 Commits

Reviewing files that changed from the base of the PR and between fd7f1e1 and 2d122ab.

📒 Files selected for processing (2)
  • Lite/Services/RemoteCollectorService.FileIo.cs
  • install/20_collect_file_io_stats.sql

📝 Walkthrough

Walkthrough

Modified null-handling logic in file I/O statistics collection queries across two SQL files. Changed fallback values for database_name, file_name, file_type, and physical_name when metadata is missing or null.

Changes

Cohort / File(s) Summary
File I/O Stats Collection Queries
Lite/Services/RemoteCollectorService.FileIo.cs, install/20_collect_file_io_stats.sql
Adjusted null-handling and fallback values in metadata column selection: database_name now falls back to DB_NAME(vfs.database_id) instead of literal values; file_name now constructs fallback as 'File_' + CONVERT(nvarchar(10), vfs.file_id) instead of literals; file_type falls back to N'UNKNOWN'; physical_name wrapped with ISNULL() to ensure empty string when null.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/file-io-null-masterfiles-633
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant