Skip to content

fix(platform): surface approval rejection ConvexError codes in all approval cards (#2009) - #2259

Merged
cursor[bot] merged 4 commits into
mainfrom
tale/xs7970c1b3b7w6k7qrgy60jwwh89ftea
Jul 3, 2026
Merged

cursor[bot] merged 4 commits into
mainfrom
tale/xs7970c1b3b7w6k7qrgy60jwwh89ftea

Conversation

@larryro

@larryro larryro commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

What

Closes #2009.

The backend approval mutations (approvals/mutations.ts, agent_tools/human_input/mutations.ts) were already converted to ConvexError({ code }) for every user-facing rejection in #2172. However, only the integration approval card and the human-input card actually mapped those structured codes to actionable messages.

The five remaining approval cards still did:

setError(err instanceof Error ? err.message : t('errorXFailed'));

For a ConvexError, err.message is the prod-redacted opaque "Server Error" string — the structured code lives on err.data. So rejecting an approval (or hitting UNAUTHENTICATED / NOT_FOUND) in these cards surfaced an opaque server error, exactly the symptom #2009 describes.

Changes

  • Extracted mapApprovalError (previously local to integration-approval-card.tsx) into a shared app/features/chat/lib/map-approval-error.ts, with its unit test moved alongside.
  • Routed the error handling in all five remaining approval cards through mapApprovalError, keying off the structured ConvexError code and falling back to the card's generic message for anything unrecognized:
    • workflow-run-approval-card.tsx
    • workflow-update-approval-card.tsx
    • workflow-creation-approval-card.tsx
    • document-write-approval-card.tsx
    • knowledge-write-approval-card.tsx
  • integration-approval-card.tsx now imports the shared helper.

Verification

  • vitest (UI project): chat feature suite — 727 tests pass, including the migrated map-approval-error.test.ts.
  • tsc --noEmit: clean.
  • oxlint --type-aware on all changed files: 0 warnings, 0 errors.

@larryro

larryro commented Jun 28, 2026

Copy link
Copy Markdown
Contributor Author

Desk review — #2259 (fixes #2009)

Verdict: NOT READY — one blocking gap. CI is fully green and the UI test suite passes (727 chat tests + the migrated map-approval-error.test.ts). The refactor itself is clean and correct: the shared mapApprovalError helper, the APPROVAL_ERROR_KEYS/translate i18n-scanner workaround, the removal of the old local copy, and the routing of all six approval cards (with tCommon in every call site) are all sound. The mapped codes (UNAUTHENTICATED, NOT_FOUND, ALREADY_RESOLVED) match what updateApprovalStatus/removeRecommendedProduct (and their helper) actually throw.

🔴 Blocking — the human-input Submit path is left opaque (in scope of #2009)

app/features/chat/components/workflow-run-approval-card.tsx:294-300 — the WorkflowHumanInputSection onSubmit → submitHumanInput onError handler still does:

onError: (err) => {
  setError(err instanceof Error ? err.message : tCommon('errorSubmitFailed'));
},

This is the exact bug #2009 describes, and the issue calls it out by name: "Human input responses are directly user-triggered (the 'Submit' button in the approval card). When the server rejects, the user sees no feedback." The mutation here (useSubmitHumanInputResponse → convex/agent_tools/human_input/mutations.ts) throws ConvexError({ code }) with NOT_FOUND, NOT_EDITABLE, WORKFLOW_NOT_EDITABLE, ALREADY_RESPONDED, INVALID_TYPE, NO_THREAD, GENERATION_IN_PROGRESS, and BUDGET_EXCEEDED. Reading err.message yields the prod-redacted "Server Error" for every one of them — err.data.code is the only thing that survives. This handler is reachable (gated on isWaitingForHumanInput && humanInputApproval, the paused-workflow human-input state) and was not touched by this PR (only the approve/reject/cancel handlers were).

Fix: route this onError through the existing mapHumanInputError(err, t, tCommon, fallback) (already exported from human-input-request-card.tsx, already handling exactly these codes and used by the chat-context human-input submit/edit paths at lines ~291 and ~385). Note mapApprovalError is not sufficient here — it only knows UNAUTHENTICATED/NOT_FOUND/ALREADY_RESOLVED, not the human-input codes. Consider relocating mapHumanInputError into the shared lib/ alongside mapApprovalError.

Non-blocking notes (not required to merge)

  • getOrganizationMember throws UnauthorizedError (a plain RLSError/Error, not a ConvexError), so an org-membership rejection in updateApprovalStatus falls through to the generic fallback rather than a specific message. This is not a regression (previously it was the opaque "Server Error"; now it's a generic localized string), but those rejections still aren't actionable.
  • INVALID_DECISION (from approvals/helpers.ts) is unmapped but unreachable from the cards (they only ever send executing/rejected). Fine.
  • Related (pre-existing, optional): human-input-request-card.tsx:220 (cancel-execution handler) also reads raw err.message.

NOT READY — CHANGES REQUIRED: wire the workflow-run-approval-card.tsx human-input onSubmit onError (lines 294-300) through mapHumanInputError so the human-input rejection codes surface actionable messages instead of an opaque "Server Error".

@cursor
cursor Bot merged commit c252827 into main Jul 3, 2026
51 checks passed
@cursor
cursor Bot deleted the tale/xs7970c1b3b7w6k7qrgy60jwwh89ftea branch July 3, 2026 13:29
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.

Bug: approvals mutations + human_input mutations throw raw Error — approval rejections are opaque Server Errors

1 participant