#14652·onyx

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:

typescript
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:

  1. The error body is not JSON. validate_bot_token, validate_app_token and validate_user_token (backend/onyx/server/manage/validate_tokens.py) call the Slack API with requests.post. If that call raises, for example on a network error or a timeout, the exception is not an HTTPException. The backend has no generic Exception handler, so the server sends a plain-text Internal 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.
  2. The JSON body has no detail and no message. errorMsg is undefined, and errorMsg.includes(...) throws a TypeError. The current backend handlers always send detail, so this case is less likely.

Steps to reproduce

  1. Open Admin > Slack bots > New.
  2. Make the backend unable to reach slack.com, for example by blocking outbound network access.
  3. 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).