Skip to content

Fix backend error handler#1351

Open
dobesv wants to merge 3 commits intokagent-dev:mainfrom
dobesv:ui-error-handler-fixup
Open

Fix backend error handler#1351
dobesv wants to merge 3 commits intokagent-dev:mainfrom
dobesv:ui-error-handler-fixup

Conversation

@dobesv
Copy link
Copy Markdown
Contributor

@dobesv dobesv commented Feb 20, 2026

I noticed that when kagent-controller was down, the UI showed the wrong error "Agent not found". According to claude code, this change should fix it to show a more specific error. Basically it seems like some code was expecting error to be set for errors, so this sets error and message both to handle those cases.

Copilot AI review requested due to automatic review settings February 20, 2026 23:50
@dobesv dobesv requested a review from peterj as a code owner February 20, 2026 23:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug in the error handling logic where specific backend error messages were not being properly propagated to the UI. When the kagent-controller service was down, users would see a generic "Agent not found" error instead of the actual error message like "Network error - Could not reach backend server."

Changes:

  • Updated createErrorResponse function to populate the error field in addition to the existing message field, ensuring error responses conform to the BaseResponse<T> interface

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

const errorMessage = error instanceof Error ? error.message : defaultMessage;
console.error(defaultMessage, error);
return { message: errorMessage };
return { message: errorMessage, error: errorMessage };
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

Both 'message' and 'error' are set to the same value (errorMessage), creating redundancy. Consider setting 'message' to the defaultMessage parameter to provide context about what operation failed, while 'error' contains the actual error details. For example: return { message: defaultMessage, error: errorMessage }. This would make 'message' describe the operation context (e.g., "Error getting agent") and 'error' contain the specific error (e.g., "Network error - Could not reach backend server").

Suggested change
return { message: errorMessage, error: errorMessage };
return { message: defaultMessage, error: errorMessage };

Copilot uses AI. Check for mistakes.
Signed-off-by: Dobes Vandermeer <dobes.vandermeer@newsela.com>
@dobesv dobesv force-pushed the ui-error-handler-fixup branch from 95e6cf7 to f1ecefd Compare March 8, 2026 07:47
@dobesv
Copy link
Copy Markdown
Contributor Author

dobesv commented Mar 20, 2026

I notice you approved but did not merge - are you thinking I would merge? Or is there some automated process that would merge it? I don't have the ability to merge it.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 4, 2026

This pull request has been marked as stale because of no activity in the last 15 days. It will be closed in the next 5 days unless it is tagged "no stalebot" or other activity occurs.

@github-actions github-actions bot added the stale This issue or PR has become stale label Apr 4, 2026
@lwencel
Copy link
Copy Markdown

lwencel commented Apr 7, 2026

@peterj could you help to merge this change?

@github-actions github-actions bot removed the stale This issue or PR has become stale label Apr 8, 2026
@dobesv dobesv requested a review from peterj April 11, 2026 01:45
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.

4 participants