Slack bot form: no error shows when the error response is not JSON
Author: jmelahmanCreated Sep 11, 2026Updated Sep 11, 2026
Labelsbug
Problem
In web/src/app/admin/bots/SlackTokensForm.tsx, the submit handler reads the error body like this:
const responseJson = await response.json();
let errorMsg = responseJson.detail || responseJson.message;
if (errorMsg.includes("Invalid bot token:")) { ... }This code has no fallback in two cases:
- The error body is not JSON.
validate_bot_token,validate_app_tokenandvalidate_user_token(backend/onyx/server/manage/validate_tokens.py) call the Slack API withrequests.post. If that call raises, for example on a network error or a timeout, the exception is not anHTTPException. The backend has no genericExceptionhandler, so the server sends a plain-textInternal Server Error. A proxy error page (502 or 504) is also not JSON.response.json()then rejects, the submit handler stops, and no toast shows. The user gets no feedback. - The JSON body has no
detailand nomessage.errorMsgisundefined, anderrorMsg.includes(...)throws aTypeError. The current backend handlers always senddetail, so this case is less likely.
Steps to reproduce
- Open Admin > Slack bots > New.
- Make the backend unable to reach
slack.com, for example by blocking outbound network access. - Submit the form with any tokens.
Expected: an error toast shows. Actual: no toast shows, and the browser console shows an unhandled promise rejection.
Suggested fix
Read the body with .catch(() => ({})), and use a translated fallback message when detail and message are not strings.
Found while typing JSON responses for the type coverage work (#14650).
Source: onyx-dot-app/onyx