Skip to content

Fix Service Broker objects not displayed in Object Explorer#2629

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-service-broker-display-issue
Draft

Fix Service Broker objects not displayed in Object Explorer#2629
Copilot wants to merge 3 commits intomainfrom
copilot/fix-service-broker-display-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 18, 2026

Service Broker sub-items (Message Types, Contracts, Queues, Services, etc.) always showed empty in the Object Explorer because child queriers never found a ServiceBroker parent.

Root Cause

ServiceBroker extends SqlSmoObject, not NamedSmoObject, so it cannot be stored via the standard SmoTreeNode.CacheInfoFromModel mechanism. The "Service Broker" node was a plain FolderNode whose GetContext() delegates upward — meaning child queriers received a context with Parent = Database instead of Parent = ServiceBroker, causing the as ServiceBroker cast to always return null.

Changes

  • ServiceBrokerFolderNode.cs (new): Overrides GetContext() to fetch db.ServiceBroker from the database context and return a CopyWithParent(serviceBroker) context. Child folder nodes inherit this via the FolderNode delegation chain:

    public override object GetContext()
    {
        SmoQueryContext parentContext = Parent?.GetContextAs<SmoQueryContext>();
        Database db = parentContext?.Parent as Database;
        if (db?.ServiceBroker != null)
            return parentContext.CopyWithParent(db.ServiceBroker);
        return base.GetContext();
    }
  • SmoTreeNodes.cs / SmoTreeNodes.tt: DatabaseChildFactory.OnExpandPopulateFolders now instantiates ServiceBrokerFolderNode instead of FolderNode for the Service Broker node.

  • SmoQueryModel.cs / SmoQueryModel.tt: Added else logging to all Service Broker queriers that records the actual parent type when the ServiceBroker cast fails, aiding future diagnosis.

Code Changes Checklist

  • New or updated unit tests added
  • All existing tests pass (dotnet test)
  • Code follows contributing guidelines
  • Logging/telemetry updated if relevant
  • No protocol or behavioral regressions

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • bad-server-name
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/sqltoolsservice/sqltoolsservice/test/Microsoft.SqlTools.ServiceLayer.UnitTests/bin/Debug/net8.0/Microsoft.SqlTools.ServiceLayer.UnitTests.runtimeconfig.json --depsfile /home/REDACTED/work/sqltoolsservice/sqltoolsservice/test/Microsoft.SqlTools.ServiceLayer.UnitTests/bin/Debug/net8.0/Microsoft.SqlTools.ServiceLayer.UnitTests.deps.json /home/REDACTED/work/sqltoolsservice/sqltoolsservice/test/Microsoft.SqlTools.ServiceLayer.UnitTests/bin/Debug/net8.0/testhost.dll --port 46629 --endpoint 127.0.0.1:046629 --role client --parentprocessid 8231 --telemetryoptedin false (dns block)
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/sqltoolsservice/sqltoolsservice/test/Microsoft.SqlTools.ServiceLayer.UnitTests/bin/Debug/net8.0/Microsoft.SqlTools.ServiceLayer.UnitTests.runtimeconfig.json --depsfile /home/REDACTED/work/sqltoolsservice/sqltoolsservice/test/Microsoft.SqlTools.ServiceLayer.UnitTests/bin/Debug/net8.0/Microsoft.SqlTools.ServiceLayer.UnitTests.deps.json /home/REDACTED/work/sqltoolsservice/sqltoolsservice/test/Microsoft.SqlTools.ServiceLayer.UnitTests/bin/Debug/net8.0/testhost.dll --port 39011 --endpoint 127.0.0.1:039011 --role client --parentprocessid 9694 --telemetryoptedin false (dns block)
  • servername
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/sqltoolsservice/sqltoolsservice/test/Microsoft.SqlTools.ServiceLayer.UnitTests/bin/Debug/net8.0/Microsoft.SqlTools.ServiceLayer.UnitTests.runtimeconfig.json --depsfile /home/REDACTED/work/sqltoolsservice/sqltoolsservice/test/Microsoft.SqlTools.ServiceLayer.UnitTests/bin/Debug/net8.0/Microsoft.SqlTools.ServiceLayer.UnitTests.deps.json /home/REDACTED/work/sqltoolsservice/sqltoolsservice/test/Microsoft.SqlTools.ServiceLayer.UnitTests/bin/Debug/net8.0/testhost.dll --port 46629 --endpoint 127.0.0.1:046629 --role client --parentprocessid 8231 --telemetryoptedin false (dns block)
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/sqltoolsservice/sqltoolsservice/test/Microsoft.SqlTools.ServiceLayer.UnitTests/bin/Debug/net8.0/Microsoft.SqlTools.ServiceLayer.UnitTests.runtimeconfig.json --depsfile /home/REDACTED/work/sqltoolsservice/sqltoolsservice/test/Microsoft.SqlTools.ServiceLayer.UnitTests/bin/Debug/net8.0/Microsoft.SqlTools.ServiceLayer.UnitTests.deps.json /home/REDACTED/work/sqltoolsservice/sqltoolsservice/test/Microsoft.SqlTools.ServiceLayer.UnitTests/bin/Debug/net8.0/testhost.dll --port 39011 --endpoint 127.0.0.1:039011 --role client --parentprocessid 9694 --telemetryoptedin false (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug]: Service Broker objects are not displayed at all</issue_title>
<issue_description>### Description

The object explorer contains the item "Service Broker" with its subitems "Message Types", "Contracts", "Queues", etc. When opening a database with a complex service broker configuration, no service broker objects are displayed under the corresponding "folders".

Steps to Reproduce

  1. Connect to a database containing service broker objects
  2. In the object explorer expand the folder "Service Broker"
  3. In the folder "Service Broker" expand the subfolder "Message Types"
  4. "No Items" is displayed, also if your database contains lots of messages type definitions

Affected Area

  • Connection dialog (SQL Server | Azure browse/Fabric browse)
  • Query editor
  • Query results panel
  • Object Explorer
  • GitHub Copilot integration
  • Preview/Edit data
  • Table Designer
  • Schema Designer
  • Schema Compare
  • Local SQL Server Container provisioning
  • SQL database in Fabric provisioning
  • DACPAC/BACPAC export/import
  • SQL Database projects
  • Query Plan Visualizer
  • Other (please describe below)

If you selected "Other", please describe the affected area

No response

Environment Information

Visual Studio Code Version

Version: 1.111.0
Commit: ce099c1ed25d9eb3076c11e4a280f3eb52b4fbeb
Date: 2026-03-06T23:06:10Z
Electron: 39.6.0
ElectronBuildId: 13330601
Chromium: 142.0.7444.265
Node.js: 22.22.0
V8: 14.2.231.22-electron.0
OS: Darwin arm64 25.3.0

MSSQL Tools Version

ms-mssql.mssql-1.41.0/sqltoolsservice/5.0.20260316.3/OSX

Operating System:

macOS Tahoe 26.3.1 (25D2128)

SQL Connection

SQL Server

Confirmation

  • I have searched existing issues and couldn't find a match
  • I want to work on this issue</issue_description>

<agent_instructions>SmoQueryModel may be a good place to start. There are already queriers (SqlMessageTypeQuerier), but unclear why they're always returning empty.

In the logs, I'm seeing this:

26-03-18 8:02:06.3110500 pid:72158 tid:22 sqltools Verbose: 0 : Expanding localhost,1434/Databases/WideWorldImporters/Service Broker/Message Types
26-03-18 8:02:06.3110520 pid:72158 tid:22 sqltools Verbose: 0 : Populating oe node :localhost,1434/Databases/WideWorldImporters/Service Broker/Message Types
26-03-18 8:02:06.3111210 pid:72158 tid:22 sqltools Verbose: 0 : Begin populate children for localhost,1434/Databases/WideWorldImporters/Service Broker/Message Types using Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel.MessageTypesChildFactory factory
26-03-18 8:02:06.3113280 pid:72158 tid:22 sqltools Verbose: 0 : child factory parent :localhost,1434/Databases/WideWorldImporters/Service Broker/Message Types
26-03-18 8:02:06.3115610 pid:72158 tid:22 sqltools Verbose: 0 : Begin query MessageType
26-03-18 8:02:06.3115700 pid:72158 tid:22 sqltools Verbose: 0 : End populate children for localhost,1434/Databases/WideWorldImporters/Service Broker/Message Types using Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel.MessageTypesChildFactory factory
26-03-18 8:02:06.3116040 pid:72158 tid:21 sqltools Verbose: 0 : Done with binding operation for localhost,1434/Databases/WideWorldImporters/Service Broker/Message Types

Because there's no "Parent of type ServiceBroker found" or "End query MessageType", maybe the parent type is wrong.

Also, upgrade the logging in src/Microsoft.SqlTools.SqlCore/ObjectExplorer/SmoModel/SmoQueryModel.tt to log the actual type of .Parent if it isn't the expected type. Look at lines 78 and 79</agent_instructions>

Comments on the Issue (you are @copilot in this section)


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Copilot AI and others added 2 commits March 18, 2026 15:40
Co-authored-by: Benjin <1609827+Benjin@users.noreply.github.com>
The Service Broker tree node was created as a FolderNode that delegated its
context to the parent (Database) node. Child queriers like SqlMessageTypeQuerier
expected context.Parent to be ServiceBroker, but always received Database -
causing them to return empty collections.

Root cause: ServiceBroker extends SqlSmoObject (not NamedSmoObject), so it
couldn't be cached in the standard SmoTreeNode mechanism.

Fix: Add ServiceBrokerFolderNode that overrides GetContext() to fetch the
ServiceBroker SMO object from the Database and return a context with it as
parent. Also add parent type mismatch logging to all service broker queriers
and the SmoQueryModel.tt template.

Co-authored-by: Benjin <1609827+Benjin@users.noreply.github.com>
Copilot AI changed the title [WIP] [Bug] Fix service broker objects not being displayed Fix Service Broker objects not displayed in Object Explorer Mar 18, 2026
Copilot AI requested a review from Benjin March 18, 2026 16:00
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.

[Bug]: Service Broker objects are not displayed at all

2 participants