fix: PowerQuery load-to state transitions, get-load-config, CLI banner#500
Merged
fix: PowerQuery load-to state transitions, get-load-config, CLI banner#500
Conversation
Fixes three bugs in PowerQuery and CLI: 1. CLI banner to stdout (#497) - RenderHeader() created an AnsiConsole targeting stderr so JSON output on stdout is never polluted by the banner. - Console.IsOutputRedirected is false in VS Code integrated terminal, so the previous redirect guard did not protect piped usage. 2. load-to connection-only no-op on loaded queries (#498) - LoadTo now calls UnloadFromDestinations before applying any new load mode, covering all state transitions in all directions: LoadToTable→ConnectionOnly, LoadToBoth→ConnectionOnly, LoadToTable→DataModel, DataModel→LoadToTable, etc. - Added 4 regression tests covering each previously missing direction. 3. get-load-config threw 0x800A03EC for connection-only queries (#499) - Added missing COMException guard on .QueryTable access inside GetLoadConfig. Every other .QueryTable access site already had this guard; GetLoadConfig was the one missed location.
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
This was referenced Feb 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug Fixes
Fixes three related bugs in PowerQuery and CLI.
Bug #1 — CLI banner written to stdout (#497)
Problem: The startup banner was printed to stdout, polluting JSON output. \�xcelcli powerquery list ... | ConvertFrom-Json\ would fail.
Root Cause: \Console.IsOutputRedirected\ is \alse\ in the VS Code integrated terminal, bypassing the existing redirect guard.
Fix: \RenderHeader()\ now creates a dedicated stderr-targeted \AnsiConsole\ instance.
File: \src/ExcelMcp.CLI/Program.cs\
Bug #2 — \load-to connection-only\ was a no-op on loaded queries (#498)
Problem: Calling \powerquery load-to --destination connection-only\ on a query already loaded to a worksheet returned \success: true\ but left the ListObject and connection in place.
Root Cause: The \ConnectionOnly\ case returned early without calling \UnloadFromDestinations.
Fix: \LoadTo\ now always calls \UnloadFromDestinations\ before applying any new load mode, covering all state transitions in all directions.
File: \src/ExcelMcp.Core/Commands/PowerQuery/PowerQueryCommands.LoadTo.cs\
Regression tests added (4):
Bug #3 — \get-load-config\ threw COMException 0x800A03EC for connection-only queries (#499)
Problem: \GetLoadConfig\ threw a raw COMException for queries in connection-only mode (which have no ListObject/QueryTable).
Root Cause: \GetLoadConfig\ accessed .QueryTable\ without guarding against the COM exception that fires when no QueryTable exists. Every other .QueryTable\ access site already had this guard; this was the one missed location.
Fix: Added the same \catch (COMException ex) when (ex.HResult == unchecked((int)0x800A03EC))\ guard.
File: \src/ExcelMcp.Core/Commands/PowerQuery/PowerQueryCommands.Lifecycle.cs\
Test Coverage
Backwards Compatibility
✅ Fully backwards compatible — no interface changes, no parameter changes.