Skip to content

Fix - Lite - [ERROR] [FinOps] Recommendation check failed (Enterprise features): Invalid column name 'database_id'.#777

Closed
dphugo wants to merge 6 commits into
erikdarlingdata:devfrom
dphugo:fix/finops-sku-features-dbname
Closed

Fix - Lite - [ERROR] [FinOps] Recommendation check failed (Enterprise features): Invalid column name 'database_id'.#777
dphugo wants to merge 6 commits into
erikdarlingdata:devfrom
dphugo:fix/finops-sku-features-dbname

Conversation

@dphugo
Copy link
Copy Markdown
Contributor

@dphugo dphugo commented Apr 2, 2026

  • I noticed the following error in the Log file:

[ERROR] [FinOps] Recommendation check failed (Enterprise features): Invalid column name 'database_id'.

  • I traced the root cause and found that:
  • The table sys.dm_db_persisted_sku_features does not have a column database_id, which causes the query to error.
  • removed database_id from DB_NAME() funciton

What does this PR do?

In Lite edition, fixes bug where invalid column database_id is selected.
Note: I don't have an environment to build and test the Full Edition, but the same issue is there as well. I will raise an issue to discuss this category further.

Which component(s) does this affect?

  • Full Dashboard
  • Lite Dashboard
  • Lite Tests
  • SQL collection scripts
  • CLI Installer
  • GUI Installer
  • Documentation

How was this tested?

Describe the testing you've done. Include:

  • SQL Server version(s) tested against: SQL Server 2022 (RTM-CU16)

Steps to verify the change works:

  • I removed the database_id reference.
  • Rebuild and ran Lite edition
  • Error no longer occurs
  • FinOps -> Recommendations now shows Licensing Category suggestion related to this query
image

Checklist

  • I have read the contributing guide
  • My code builds with zero warnings (dotnet build -c Debug)
  • I have tested my changes against at least one SQL Server version
  • I have not introduced any hardcoded credentials or server names

Some warnings on other code objects

So my code builds with zero warnings, but there are warnings on other objects. I assume these were introduced by a previous commit.

..\PerformanceMonitor>dotnet build -c Debug
Restore complete (1.3s)
  Installer.Core succeeded (6.7s) → Installer.Core\bin\Debug\net8.0\Installer.Core.dll
  PerformanceMonitorLite succeeded with 3 warning(s) (8.2s) → Lite\bin\Debug\net8.0-windows\PerformanceMonitorLite.dll
    ..\PerformanceMonitor\Lite\Controls\ServerTab.xaml.cs(804,44): warning CS8602: Dereference of a possibly null reference.
    ..\PerformanceMonitor\Lite\Services\PlanAnalyzer.cs(843,13): warning CS8602: Dereference of a possibly null reference.
    ..\PerformanceMonitor\Lite\Services\RemoteCollectorService.QueryStore.cs(225,45): warning CS8602: Dereference of a possibly null reference.
  Installer.Tests succeeded (1.6s) → Installer.Tests\bin\Debug\net8.0\Installer.Tests.dll
  PerformanceMonitorInstaller succeeded (1.9s) → Installer\bin\Debug\net8.0\win-x64\PerformanceMonitorInstaller.dll
  Lite.Tests succeeded (2.3s) → Lite.Tests\bin\Debug\net8.0-windows\Lite.Tests.dll
  Dashboard_wmndtfk2_wpftmp succeeded with 1 warning(s) (4.4s)
    ..\PerformanceMonitor\Dashboard\Services\PlanAnalyzer.cs(844,13): warning CS8602: Dereference of a possibly null reference.
  Dashboard succeeded with 1 warning(s) (11.9s) → Dashboard\bin\Debug\net8.0-windows\PerformanceMonitorDashboard.dll
    ..\PerformanceMonitor\Dashboard\Services\PlanAnalyzer.cs(844,13): warning CS8602: Dereference of a possibly null reference.

Build succeeded with 5 warning(s) in 20.2s

@dphugo dphugo marked this pull request as ready for review April 2, 2026 12:17
@erikdarlingdata
Copy link
Copy Markdown
Owner

@dphugo I thought hat got fixed here.

@erikdarlingdata
Copy link
Copy Markdown
Owner

Thanks for catching this @dphugo! You're right that the database_id column doesn't exist on all versions.

This was actually fixed for the Dashboard side in #766 using a COL_LENGTH check to detect whether the column exists and falling back to N'(unknown)' when it doesn't — that way servers that do have the column still get the database name in the output.

The Lite side was supposed to get the same fix but was missed. We've now ported the Dashboard approach to Lite (same COL_LENGTH check pattern), so closing this PR in favor of that fix. Appreciate the report!

erikdarlingdata added a commit that referenced this pull request Apr 2, 2026
…e_id column

Port the COL_LENGTH check from Dashboard (#766) to Lite — detect whether
sys.dm_db_persisted_sku_features has the database_id column before querying
it, falling back to N'(unknown)' on older builds that lack the column.

Closes community PR #777

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@erikdarlingdata erikdarlingdata mentioned this pull request Apr 8, 2026
6 tasks
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