fix: surface permission reply API errors instead of recording silent failures#35
Merged
Merged
Conversation
…failures
Managed clients use responseStyle "fields" without throwOnError, so a
failed permission.reply resolves as { error } rather than throwing.
replyToPendingApprovals never inspected the result, so API failures were
silently recorded as replied and the approval was never retried.
Check the result via extractSdkResult, matching the question-handling
fix in #33: on error, log a warning, surface it in the response
warnings, and skip adding the id to repliedApprovalIds so the next turn
retries the reply.
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.
Summary
replyToPendingApprovalscalledpermissionApi.reply({...})inside a try/catch but never inspected the resolved value. The provider creates OpenCode SDK v2 clients withresponseStyle: "fields"and nothrowOnError(seecreateManagedClientOptionsinsrc/opencode-client-manager.ts), so API-level failures resolve as{ data, error }rather than throwing. A failed permission reply was therefore silently recorded as replied (repliedApprovalIds.add(...)) with no warning, and the approval was never retried — OpenCode kept waiting on the permission request.Fix
Same pattern as the question-handling fix in #33:
permission.replyresult through the existingextractSdkResulthelper.error: log a warning, push it to the responsewarningsarray, and skip adding the id torepliedApprovalIdsso the next turn retries the reply.Tests
Added a unit test where
mockClient.permission.replyresolves with{ error: {...} }, asserting:doGenerateresult'swarningsarraydoGeneratewith the same prompt callspermission.replyagain (the failed approval id is not recorded as replied)Verification
npm test— 391 tests passingnpm run typecheck— cleannpm run lint— 0 errors, 7 pre-existing warnings (unchanged from main)npm run build— success