Skip to content

fix: exception message mismatch in in-memory emulator#55

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-inmemory-emulator-exception-message
Draft

fix: exception message mismatch in in-memory emulator#55
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-inmemory-emulator-exception-message

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 23, 2026

Three related exception-message bugs in InMemoryContainer caused inconsistent error text across typed-API operations and between the typed-API and FakeCosmosHandler code paths.

Changes

Typed-API NotFound (404) inconsistency

  • ReadItemAsync correctly included "in the system" but ReplaceItemAsync, DeleteItemAsync, UpsertItemAsync (with IfMatchEtag), and PatchItemAsync omitted it
  • All now use shared constant MessageEntityDoesNotExist = "Entity with the specified id does not exist in the system."

Wrong PreconditionFailed (412) message

Stream API error responses lacked JSON body

  • Stream methods returned bare 404/409/412 with null Content; when flowing through FakeCosmosHandler → ConvertToHttpResponse → SDK, the SDK created CosmosException with empty Reason: () — inconsistent with the typed-API path
  • CreateResponseMessage now accepts a reason parameter that embeds {"message":"…"} in Content:
// Before: no body, SDK produces Reason: ()
return CreateResponseMessage(HttpStatusCode.NotFound);

// After: SDK surfaces the same message as the typed API
return CreateResponseMessage(HttpStatusCode.NotFound,
    reason: $"{MessageEntityDoesNotExist} id = {id}");

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Checklist

  • Tests added/updated (TDD: failing test first, then implementation)
  • All tests pass (dotnet test)
  • No new warnings introduced

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:

  • learn.microsoft.com
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

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

Original prompt

Can you analyse this bug report, verify it's accuracy carefully and in depth, and if it's a genuine bug, fix it

"C:\bug-reports\cosmos\inmemory-emulator-exception-message-mismatch.md"

The user has attached the following file paths as relevant context:

  • .github\copilot-instructions.md
  • AGENTS.md

Created from VS Code.

Copilot AI changed the title [WIP] Fix exception message mismatch in in-memory emulator fix: exception message mismatch in in-memory emulator Apr 23, 2026
Copilot AI requested a review from lemonlion April 23, 2026 12:48
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