Improve error handling in Jira Cloud auth validation#2114
Conversation
|
There was a problem hiding this comment.
Pull request overview
Improves Jira Cloud custom auth validation error handling so failed validation returns a safe error string instead of attempting to access nested HTTP response fields that may not exist (OPS-3427).
Changes:
- Update Jira Cloud auth
validatecatch block to use the thrown error’s message with a fallback string.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| return { | ||
| valid: false, | ||
| error: ((e as HttpError).response.body as any).message, | ||
| error: (e as HttpError)?.message ?? 'Invalid credentials', |
There was a problem hiding this comment.
HttpError.message is set to JSON.stringify({ response, request }) (see packages/blocks/common/src/lib/http/core/http-error.ts), so returning (e as HttpError)?.message will often surface a large JSON blob rather than a user-friendly message (and could include request details in other call sites). Since sendJiraRequest wraps HttpError into a plain Error(fullError) anyway, consider using runtime checks (e instanceof Error) and extracting/parsing Jira’s error body (e.g., errorMessages[0]) with a safe fallback.



Fixes OPS-3427