Skip to content

Add read-only doctor diagnostics and identity context - #209

Merged
Mike Krüger (mkrueger) merged 9 commits into
mainfrom
dev/mkrueger/doctor-diagnostics
Sep 10, 2026
Merged

Mike Krüger (mkrueger) merged 9 commits into
mainfrom
dev/mkrueger/doctor-diagnostics

Conversation

@mkrueger

@mkrueger Mike Krüger (mkrueger) commented Sep 10, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Add a doctor command for bounded, read-only environment and connection diagnostics without changing the current connection or navigation.

  • Report local environment, DNS, and account/database/container metadata access, with optional query and ARM probes.
  • Provide versioned JSON reports and MCP results, including failing checks and request charges observed from completed probes.
  • Add doctor who and doctor --who for known credential type, selected scope, and explicitly unassessed write access.
  • Color status verdicts using theme roles, including a configurable success color, and respect the executing shell's quiet setting.
  • Classify HTTP, nested TLS/DNS, socket, proxy-authentication, and credential failures without exposing raw exception text. Give ARM-specific guidance for forbidden access.
  • Add command and process-level regression coverage, localized help, and CLI/MCP documentation.

Behavior and Limits

Credentials that may initiate interactive login are not probed. The query probe reads one constant-projection response page; successful reads do not establish write permissions or access to every partition. Each network check has a five-second limit within the configurable overall deadline.

Local DNS resolution remains a prerequisite for data-plane probes. The report omits endpoints, resource names, principal IDs, tokens, keys, and document data; the standard MCP envelope still includes the current location.

image

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

DoctorCommand’s credential probe gating uses the runtime credential type name rather than the connection’s recorded credential type, which can incorrectly skip/fail probes in valid configurations.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR adds a new doctor diagnostics command to CosmosDBShell, providing bounded, read-only environment and connectivity checks (optionally including a single-page query probe and ARM metadata probe) without changing the current connection or navigation. It also extends theming to support a dedicated success color for PASS-style status rendering and updates docs/localization plus test coverage.

Changes:

  • Introduces doctor command with versioned JSON reporting, optional identity context (doctor who / --who), and bounded DNS/data-plane/query/ARM probes.
  • Adds success theme key and Theme.FormatSuccess() for coloring PASS verdicts (and sample output).
  • Updates docs and localization strings; adds command/process regression tests for doctor.
File summaries
File Description
README.md Documents doctor and the new theme verdict color keys.
l10n/CosmosDBShell.json Adds localized strings for doctor help and verdict messages.
docs/navigation.md Clarifies doctor scope selection behavior without navigation.
docs/mcp.md Documents MCP usage/limits for the read-only doctor tool.
docs/commands.md Adds full doctor command documentation, limits, and troubleshooting codes.
CosmosDBShell/lang/en.ftl Adds Fluent localization keys used by doctor.
CosmosDBShell/Azure.Data.Cosmos.Shell.Core/ThemeProfiles.cs Adds SuccessColor to the monochrome profile.
CosmosDBShell/Azure.Data.Cosmos.Shell.Core/ThemeOptions.cs Introduces SuccessColor option with a default.
CosmosDBShell/Azure.Data.Cosmos.Shell.Core/ThemeFile.cs Supports success key in theme files.
CosmosDBShell/Azure.Data.Cosmos.Shell.Core/Theme.cs Adds Theme.FormatSuccess() helper for success/pass styling.
CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/ThemeCommand.cs Shows a success-colored sample row in theme output.
CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/DoctorCommand.cs Implements the new read-only doctor diagnostics command.
CosmosDBShell.Tests/Integration/ShellProcessTests.cs Adds process-level exit code + JSON schema assertions for doctor.
CosmosDBShell.Tests/CommandTests/DoctorCommandTests.cs Adds unit tests for doctor behavior, redaction, classification, and MCP annotation.
Review details
  • Files reviewed: 14/14 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI review requested due to automatic review settings September 10, 2026 12:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

doctor who subcommand handling is currently case-sensitive/inconsistent with other subcommand commands in the repo, and should be normalized (trim + case-insensitive) before approval.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (1)

CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/DoctorCommand.cs:67

  • doctor rejects any Subcommand other than exactly "who", which makes the alias unexpectedly case-sensitive compared to the rest of the CLI’s subcommand parsing. Consider normalizing with Trim() + case-insensitive comparison before validation (consistent with other subcommand commands).
        if (this.Subcommand != null && this.Subcommand != "who")
        {
            throw new CommandException("doctor", Message("invalid-subcommand"));
        }
  • Files reviewed: 18/18 changed files
  • Comments generated: 1
  • Review effort level: Lite
Copilot AI review requested due to automatic review settings September 10, 2026 12:49
@github-code-quality

github-code-quality Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Code Coverage Overview

Languages: C#

C# / code-coverage/dotnet

The overall line coverage in commit 159edac in the dev/mkrueger/doctor-... branch is 63%. The line coverage in commit edf54d7 in the main branch is 62%.

Show a line coverage summary of the most impacted files.
File main edf54d7 dev/mkrueger/doctor-... 159edac +/-
D:\a\CosmosDBSh...ThemeCommand.cs 60% 60% 0%
D:\a\CosmosDBSh...re\ThemeFile.cs 96% 96% 0%
D:\a\CosmosDBSh...lInterpreter.cs 66% 66% 0%
D:\a\CosmosDBSh...ThemeOptions.cs 100% 100% 0%
D:\a\CosmosDBSh...hemeProfiles.cs 100% 100% 0%
D:\a\CosmosDBSh...l.Core\Theme.cs 75% 76% +1%
D:\a\CosmosDBSh...ponseFactory.cs 92% 97% +5%
D:\a\CosmosDBSh...pdateChecker.cs 0% 80% +80%
D:\a\CosmosDBSh...octorCommand.cs 0% 99% +99%
D:\a\CosmosDBSh...osmosContext.cs 0% 100% +100%

Updated September 10, 2026 13:02 UTC

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

It introduces a sizeable new diagnostics surface area with multiple network/credential/ARM code paths and operational/security implications that merits final human validation despite strong test coverage.

Review details
  • Files reviewed: 18/18 changed files
  • Comments generated: 0 new
  • Review effort level: Lite
Copilot AI review requested due to automatic review settings September 10, 2026 12:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

It adds a large new diagnostics command with multiple network/credential/ARM execution paths and nuanced failure classification that warrants final human review.

Review details
  • Files reviewed: 18/18 changed files
  • Comments generated: 0 new
  • Review effort level: Lite
@mkrueger
Mike Krüger (mkrueger) merged commit 7271532 into main Sep 10, 2026
12 checks passed
@mkrueger
Mike Krüger (mkrueger) deleted the dev/mkrueger/doctor-diagnostics branch September 10, 2026 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants