Skip to content

Improve emulator connection failure message#84

Open
mkrueger wants to merge 2 commits into
mainfrom
dev/mkrueger/issue74
Open

Improve emulator connection failure message#84
mkrueger wants to merge 2 commits into
mainfrom
dev/mkrueger/issue74

Conversation

@mkrueger
Copy link
Copy Markdown
Contributor

@mkrueger mkrueger commented May 12, 2026

Improves the failure message when connect to a local Cosmos DB emulator endpoint fails.

Before:

Failed to connect to the Cosmos DB account.

After (HTTPS attempt):

Could not reach the Cosmos DB emulator at https://localhost:8081/.
Make sure the emulator is running and reachable.
If the protocol is wrong, try http://localhost:8081/ (the Linux emulator defaults to HTTP).
The emulator container's protocol is set with --protocol [https|http].
See: https://learn.microsoft.com/en-us/azure/cosmos-db/emulator-linux

The suggested alternate URL flips the scheme so the user can copy-paste it.

Fixes #74

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the user-facing error message shown when connecting to a local Cosmos DB emulator endpoint fails, providing actionable guidance (including a copy/paste alternate URL with the flipped scheme) to reduce confusion around HTTP vs HTTPS emulator setups.

Changes:

  • Adds a new localized error string (error-emulator_connection_failed) with emulator-specific troubleshooting guidance.
  • Updates ShellInterpreter.ConnectAsync to throw the emulator-specific message when an emulator connection attempt fails.
  • Adds unit tests validating the generated emulator failure message content and scheme-flip suggestion.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
CosmosDBShell/lang/en.ftl Adds a new localized emulator-specific connection failure message with endpoint/alternate placeholders.
CosmosDBShell/Azure.Data.Cosmos.Shell.Core/ShellInterpreter.cs Routes emulator connection failures to a new message generator and adds URI scheme-flip helper.
CosmosDBShell.Tests/CommandTests/ConnectCommandTests.cs Adds tests asserting the emulator failure message includes key guidance and the correct alternate URL.

Comment thread CosmosDBShell/Azure.Data.Cosmos.Shell.Core/ShellInterpreter.cs Outdated
- Preserve underlying exception as inner exception for emulator path so --verbose still shows diagnostics (addresses Copilot review feedback).
- Expand emulator failure guidance: mention 'docker ps' check, the http://localhost:8080/alive health probe, the SDK HTTPS requirement, and a ready-to-paste docker run example with --protocol https.
- Extend tests to cover the new content.
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.

Reducing friction in using the shell with the emulator

3 participants