Hmbown/CodeWhale · error · Error
${name} is required
Error message
${name} is required What it means
wecom-bridge's lib.mjs requiredEnv(name) throws `${name} is required` when the env var is unset or whitespace-only. The WeCom bridge requires WECOM_BOT_ID (index.mjs:37), WECOM_BOT_SECRET (index.mjs:38) and CODEWHALE_RUNTIME_TOKEN (index.mjs:40); the message names whichever one is missing. Startup aborts before any WeCom or runtime call.
Source
Thrown at integrations/wecom-bridge/src/lib.mjs:36
export {
activeTurnBlock,
cleanEnvValue,
compactRuntimeError,
isPlaceholderValue,
latestRunningTurn,
parseApprovalDecisionArgs,
parseBool,
parseCommand,
parseList,
preservedChatStateFields,
splitMessage
};
export function requiredEnv(name) {
const value = process.env[name];
if (!value || !value.trim()) {
throw new Error(`${name} is required`);
}
return value.trim();
}
export function parseTextContent(content) {
return coreParseTextContent(content, ["text"]);
}
export function incomingIdentity(body) {
const from = body?.from || {};
const chatId = body.chatid || (body.chattype === "single" && from.userid ? `single:${from.userid}` : "");
return {
chatId,
messageId: body.msgid || "",
chatType: body.chattype || "single",
userId: from.userid || "",
aibotId: body.aibotid || ""
};View on GitHub (pinned to 8880682c63)
Solutions
- Set WECOM_BOT_ID and WECOM_BOT_SECRET from the WeCom app's credential page
- Set CODEWHALE_RUNTIME_TOKEN to the token the Codewhale runtime accepts
- Identify the missing one with `printenv WECOM_BOT_ID WECOM_BOT_SECRET CODEWHALE_RUNTIME_TOKEN` and restart once all print non-empty
Example fix
# before node src/index.mjs # after WECOM_BOT_ID='xxx' WECOM_BOT_SECRET='yyy' CODEWHALE_RUNTIME_TOKEN='zzz' node src/index.mjs
Defensive patterns
Strategy: validation
Validate before calling
for (const name of ['WECOM_BOT_ID', 'WECOM_BOT_SECRET', 'CODEWHALE_RUNTIME_TOKEN']) {
if (!process.env[name]?.trim()) {
console.error(`${name} is required`);
process.exit(2);
}
} Try / catch
try {
startBridge();
} catch (error) {
if (/is required$/.test(error.message)) {
console.error(`Missing environment variable: ${error.message}`);
process.exit(2);
}
throw error;
} Prevention
- Keep the three required names in the unit's Environment= or --env-file and lint for them in CI
- Validate a staging instance with the same env shape as production before deploy
When it happens
Trigger: Launching the WeCom bridge without one of WECOM_BOT_ID, WECOM_BOT_SECRET, or CODEWHALE_RUNTIME_TOKEN exported, or with whitespace-only values.
Common situations: WeCom app credentials never copied from the WeCom admin console into .env; container unit missing one variable; a secret removed or renamed during rotation.
Related errors
- ${name} is required
- ${names.join(" or ")} is required
- ${name} is required
- CF_ACCOUNT_ID and CF_API_TOKEN are required
- version must be a semantic release identifier
AI-assisted analysis of Hmbown/CodeWhale@8880682c63 (2026-08-16).
Data as JSON: /api/errors/b9dbd30f4199019c.
Report an issue: GitHub.