Repository navigation
fix: an API exception message does not double the server's closing period - #975
Merged
Merged
Conversation
…riod The default message in packages/server/src/middleware/defect-response.ts at the opencode v2.3.2 pin already ends in a period. Preserve closing periods, exclamation marks and question marks when composing the API exception message. Add GetMessageAsync_Should_Read_The_Readable_500_On_An_Undeclared_Status, GetMessageAsync_Should_Keep_The_Bare_Status_Sentence_For_An_Empty_500, and ListMessages_Should_Read_The_Readable_500_As_The_Declared_UnknownError contract rows.
Merged
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.
📝 Description
What does this PR do?
Since opencode 2.3.2, a handler defect gets a readable 500 instead of an empty one (
packages/server/src/middleware/defect-response.tsat the pin):{"_tag":"UnknownError","message":"Server failed to handle the request. Check server logs for details.","ref":"err_…"}The SDK already reads that body.
OpenCodeApiExceptionbuilds its message from the status, the tag and the server's message, but it always appended a period. Because the server's message already ends in one, every readable 500 read "… Check server logs for details..".The fix (
OpenCodeErrorReader.CreateApiException): the period is appended only when the server's message doesn't already end in.,!or?. Every other message keeps its current text.New contract rows (
OpenCodeClientContractTests):session.message.get, whose 500 is undeclared, the defect body becomesUnknownOpenCodeError("UnknownError")with the message "The opencode API returned status 500 ('UnknownError'): Server failed to handle the request. Check server logs for details." The raw body keeps theref.session.message.list, which declares the 500, the body reads as the typedUnknownError, with itsMessageandRef.Related Issue(s):
None. The finding came from the 2.3.2 refresh review. The rule appends the period only when the message has no sentence ending, so every existing contract row stays unchanged, including the one whose message ends in "! " (with a trailing space).
Other places that build a sentence from server text:
CreateApiException, so this fix covers it.🔄 Type of Change
🎯 Protocol & API Surface
OpenCodeApiException.Messagechanges, and only when the server's message already ends a sentence.spec/) is untouchedexternal/was hand-edited🧪 Testing
Messageassertion: the actual message ends in "details..". With the fix, it passes on net10.0, net11.0 and net472.OpenCodeApiExceptionmessage passes unchanged.✅ Completion Gate
quality-gates.mdpasses on the head rebased ontomaster: whitespace, format/style, clones, slopwatch, the release build, all test projects, the API snapshots,generate --verify, the fixed point, Extensions and Native AOT.📚 Documentation
CHANGELOG.mdentry added under[Unreleased](🐛 Fixes)✅ Code Quality Checklist
🔍 Additional Notes
Breaking Changes: none. Dependencies: none.