Mintplex-Labs/anything-llm · error
chatId is required.
Error message
chatId is required.
What it means
The 400 reply from POST /telegram/approve-user when the JSON body contains no chatId. The endpoint approves a pending Telegram user by chat id; chatId is the only required field and reqBody(request) returned an object without it (missing, empty string, null, or a body that failed to parse).
Source
Thrown at server/endpoints/telegram.js:235
const connector = await ExternalCommunicationConnector.get("telegram");
const approved = connector?.config?.approved_users || [];
return response.status(200).json({ users: approved });
} catch (e) {
console.error(e.message, e);
response.sendStatus(500);
}
}
);
app.post(
"/telegram/approve-user",
[validatedRequest, isSingleUserMode],
async (request, response) => {
try {
const { chatId } = reqBody(request);
if (!chatId)
return response
.status(400)
.json({ success: false, error: "chatId is required." });
const service = new TelegramBotService();
await service.approvePendingUser(chatId);
await EventLogs.logEvent("telegram_user_approved", { chatId });
return response.status(200).json({ success: true });
} catch (e) {
console.error(e.message, e);
response.sendStatus(500);
}
}
);
app.post(
"/telegram/deny-user",
[validatedRequest, isSingleUserMode],
async (request, response) => {
try {View on GitHub (pinned to 3aec848f28)
Solutions
- Send {"chatId": "<numeric telegram chat id>"} with Content-Type: application/json to /telegram/approve-user.
- Get the correct chatId from EventLogs entry telegram_pending_user (logged when the unknown user first messages the bot).
- Confirm the request reaches the API with a parsed body (auth cookies attached, validatedRequest passing) - an unauthenticated body still parses but an empty payload will not.
Example fix
// before
curl -X POST /api/telegram/approve-user -d '{"chat_id": 12345}'
// after
curl -X POST /api/telegram/approve-user \
-H 'Content-Type: application/json' \
-d '{"chatId": "12345"}' Defensive patterns
Strategy: validation
Validate before calling
function approveUser(chatId) {
if (!chatId || typeof chatId !== "string" || !/^\-?\d+$/.test(chatId)) {
throw new Error("chatId must be a numeric Telegram chat id");
}
return fetch("/api/telegram/approve-user", {
method: "POST", headers: { "Content-Type": "application/json" },
body: JSON.stringify({ chatId }),
});
} Type guard
const isChatId = (v) => typeof v === "string" && /^-?\d+$/.test(v);
Prevention
- Always send Content-Type: application/json with these endpoints.
- Source chatId from the telegram_pending_user event log, never hand-type it.
- Share one helper for approve/deny/revoke so the chatId key name cannot drift.
When it happens
Trigger: POST /telegram/approve-user with an empty body, with Content-Type not application/json so the body never parses, or with a differently-cased key (chat_id, chatID). The chatId to send is the numeric Telegram chat id shown in the telegram_pending_user event log entry.
Common situations: Frontend integration sending snake_case chat_id instead of chatId; curl without -H 'Content-Type: application/json'; approving a user after the pending entry expired and guessing the field name.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- Name and config are required
- Query parameter cannot be empty.
- Message is empty
- Must be a boolean
- Device OS and name are required
AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18).
Data as JSON: /api/errors/c5252fcbcda7cc23.
Report an issue: GitHub.