Skip to content

fix: surface permission reply API errors instead of recording silent failures#35

Merged
ben-vargas merged 2 commits into
mainfrom
claude/dazzling-shockley-9715f8
Jun 11, 2026
Merged

fix: surface permission reply API errors instead of recording silent failures#35
ben-vargas merged 2 commits into
mainfrom
claude/dazzling-shockley-9715f8

Conversation

@ben-vargas

Copy link
Copy Markdown
Owner

Summary

replyToPendingApprovals called permissionApi.reply({...}) inside a try/catch but never inspected the resolved value. The provider creates OpenCode SDK v2 clients with responseStyle: "fields" and no throwOnError (see createManagedClientOptions in src/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:

  • Pass the permission.reply result through the existing extractSdkResult helper.
  • When the result carries an error: log a warning, push it to the response warnings array, and skip adding the id to repliedApprovalIds so the next turn retries the reply.
  • The thrown-error path is unchanged.

Tests

Added a unit test where mockClient.permission.reply resolves with { error: {...} }, asserting:

  • the warning reaches both the injected logger and the doGenerate result's warnings array
  • a second doGenerate with the same prompt calls permission.reply again (the failed approval id is not recorded as replied)

Verification

  • npm test — 391 tests passing
  • npm run typecheck — clean
  • npm run lint — 0 errors, 7 pre-existing warnings (unchanged from main)
  • npm run build — success

…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.
@ben-vargas
ben-vargas merged commit a43b006 into main Jun 11, 2026
3 checks passed
@ben-vargas
ben-vargas deleted the claude/dazzling-shockley-9715f8 branch June 11, 2026 20:10
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.

1 participant