Skip to content

Resolve accept invite API errors into readable messages - #45

Merged
ThaminduDilshan merged 1 commit into
thunder-id:mainfrom
PasinduYeshan:fix/expired-flow-error-handling
Aug 3, 2026
Merged

Resolve accept invite API errors into readable messages#45
ThaminduDilshan merged 1 commit into
thunder-id:mainfrom
PasinduYeshan:fix/expired-flow-error-handling

Conversation

@PasinduYeshan

@PasinduYeshan PasinduYeshan commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Purpose

The React and Vue accept invite components threw new Error("Request failed: " + body), so the raw API response body reached the UI instead of a readable message.

Approach

Throw ThunderIDAPIError instead. It runs the body through parseApiErrorMessage, so consumers get the resolved message while code, statusCode and statusText stay available. A regression test covers the resolved message.

Related Issues

Related PRs

  • N/A

Checklist

  • Followed the contribution guidelines.
  • Manual test round performed and verified.
  • Documentation provided. (Add links if there are any)
  • Tests provided. (Add links if there are any)
    • Unit Tests
    • Integration Tests
  • Breaking changes. (Fill if applicable)
    • Breaking changes section filled.
    • breaking change label added.

Security checks

  • Followed secure coding standards in WSO2 Secure Coding Guidelines
  • Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved invite acceptance error handling across React and Vue.
    • Error messages now avoid exposing internal error codes and localization keys.
    • Preserved structured error details for more consistent handling of failed requests.
    • Added regression coverage for expired invite flows.

Throw ThunderIDAPIError instead of a raw Error so the API response body is
not surfaced to users in the React and Vue accept invite components.

Refs thunder-id/thunderid#4373
@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

React and Vue AcceptInvite flows now throw ThunderIDAPIError with structured response metadata. A regression test confirms expired-flow messages exclude internal codes and localization keys while preserving the error code.

Changes

Invite-flow error handling

Layer / File(s) Summary
Structured invite-flow error propagation
packages/react/src/components/presentation/auth/AcceptInvite/AcceptInvite.tsx, packages/vue/src/components/presentation/accept-invite/AcceptInvite.ts, packages/javascript/src/errors/__tests__/ThunderIDAPIError.test.ts
React and Vue now create ThunderIDAPIError instances for failed flow execution and preserve response metadata. The regression test verifies sanitized expired-flow messages and the FES-1004 code.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: brionmario

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The description explains the problem, implementation, related issue, testing, and security checks, with only optional documentation and integration tests left unchecked.
Title check ✅ Passed The title clearly summarizes the main change: resolving accept-invite API errors into readable consumer-facing messages.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/javascript/src/errors/__tests__/ThunderIDAPIError.test.ts (1)

181-195: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Make the regression test prove the new flow behavior.

This test constructs ThunderIDAPIError directly. It can pass even if either changed AcceptInvite component still throws a raw Error or passes incorrect metadata. Add component-level tests for the React and Vue non-OK /flow/execute paths. Assert the error type, origin, stable flow code, statusCode, statusText, and parsed message.

Also assert the exact parsed message here. The current negative assertions would pass for an empty or unrelated message.

Proposed assertion
     expect(error.message).not.toContain('FES-1004');
     expect(error.message).not.toContain('error.flowexecservice');
+    expect(error.message).toBe('Invalid flow execution ID provided in the request');
     expect(error.code).toBe('FES-1004');
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/javascript/src/errors/__tests__/ThunderIDAPIError.test.ts` around
lines 181 - 195, Add component-level regression tests for both React and Vue
AcceptInvite non-OK /flow/execute paths, verifying the thrown error is a
ThunderIDAPIError with the expected origin, stable flow code, statusCode,
statusText, and parsed message. In the existing ThunderIDAPIError test, replace
the negative message checks with an exact assertion for the expected parsed
message while retaining the code assertion.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/javascript/src/errors/__tests__/ThunderIDAPIError.test.ts`:
- Around line 181-195: Add component-level regression tests for both React and
Vue AcceptInvite non-OK /flow/execute paths, verifying the thrown error is a
ThunderIDAPIError with the expected origin, stable flow code, statusCode,
statusText, and parsed message. In the existing ThunderIDAPIError test, replace
the negative message checks with an exact assertion for the expected parsed
message while retaining the code assertion.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 35109dc9-806a-4eed-a4fe-8f474fab5920

📥 Commits

Reviewing files that changed from the base of the PR and between 0f22744 and ecbef7e.

📒 Files selected for processing (3)
  • packages/javascript/src/errors/__tests__/ThunderIDAPIError.test.ts
  • packages/react/src/components/presentation/auth/AcceptInvite/AcceptInvite.tsx
  • packages/vue/src/components/presentation/accept-invite/AcceptInvite.ts

@ThaminduDilshan
ThaminduDilshan merged commit c76184f into thunder-id:main Aug 3, 2026
3 checks passed
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.

2 participants