Remove fragile error handling from sendChatHistory methods#159
Merged
pontemonti merged 2 commits intousers/johanb/RTP_OpenAIfrom Jan 27, 2026
Merged
Remove fragile error handling from sendChatHistory methods#159pontemonti merged 2 commits intousers/johanb/RTP_OpenAIfrom
pontemonti merged 2 commits intousers/johanb/RTP_OpenAIfrom
Conversation
Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix fragile 'is required' check in chat history API
Remove fragile error handling from sendChatHistory methods
Jan 27, 2026
pontemonti
approved these changes
Jan 27, 2026
pontemonti
added a commit
that referenced
this pull request
Jan 28, 2026
* Add chat history API for OpenAI * fix: update uuid and @types/uuid dependencies to use catalog * fix: correct header formatting in PRD for OpenAI sendChatHistoryAsync API * refactor: remove unnecessary logging and improve message role validation in McpToolRegistrationService * refactor: simplify role extraction in McpToolRegistrationService and remove validation * Add @types/uuid and uuid dependencies * Remove early return for empty messages in sendChatHistoryMessagesAsync (#158) * Initial plan * fix: ensure MCP call is made even when messages array is empty Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com> * Remove fragile error handling from sendChatHistory methods (#159) * Initial plan * Remove fragile 'is required' check from sendChatHistory methods Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com> * Update tests/tooling-extensions-openai/sendChatHistoryAsync.test.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fix error handling in sendChatHistoryAsync and empty array test expectations (#160) * Initial plan * Fix test failures: wrap session.getItems() in try-catch and update test expectations for empty arrays Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com> Co-authored-by: Johan Broberg <johan@pontemonti.net> * Add error handling for message conversion in sendChatHistoryMessagesAsync (#163) * Initial plan * Add error handling for convertToChatHistoryMessages and test Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com> * Address code review feedback: safer error handling and remove extra blank line Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com> --------- Co-authored-by: Johan Broberg <johanb@microsoft.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
Addresses feedback on #157 regarding fragile
err.message.includes('is required')string check in error handling. This pattern is brittle and unnecessary sincesendChatHistoryalready implements proper error contracts.Changes
sendChatHistoryAsyncandsendChatHistoryMessagesAsyncOperationErrorOperationResultBefore
After
The underlying
sendChatHistorymethod already throws validation errors and returnsOperationResult.failed()for HTTP/runtime failures, making the catch block redundant.✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.