{"record":{"id":"b9dbd30f4199019c","repo":"Hmbown/CodeWhale","slug":"name-is-required-b9dbd3","errorCode":null,"errorMessage":"${name} is required","messagePattern":"(.+?) is required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"integrations/wecom-bridge/src/lib.mjs","lineNumber":36,"sourceCode":"\nexport {\n  activeTurnBlock,\n  cleanEnvValue,\n  compactRuntimeError,\n  isPlaceholderValue,\n  latestRunningTurn,\n  parseApprovalDecisionArgs,\n  parseBool,\n  parseCommand,\n  parseList,\n  preservedChatStateFields,\n  splitMessage\n};\n\nexport function requiredEnv(name) {\n  const value = process.env[name];\n  if (!value || !value.trim()) {\n    throw new Error(`${name} is required`);\n  }\n  return value.trim();\n}\n\nexport function parseTextContent(content) {\n  return coreParseTextContent(content, [\"text\"]);\n}\n\nexport function incomingIdentity(body) {\n  const from = body?.from || {};\n  const chatId = body.chatid || (body.chattype === \"single\" && from.userid ? `single:${from.userid}` : \"\");\n  return {\n    chatId,\n    messageId: body.msgid || \"\",\n    chatType: body.chattype || \"single\",\n    userId: from.userid || \"\",\n    aibotId: body.aibotid || \"\"\n  };","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/integrations/wecom-bridge/src/lib.mjs#L18-L54","documentation":"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.","triggerScenarios":"Launching the WeCom bridge without one of WECOM_BOT_ID, WECOM_BOT_SECRET, or CODEWHALE_RUNTIME_TOKEN exported, or with whitespace-only values.","commonSituations":"WeCom app credentials never copied from the WeCom admin console into .env; container unit missing one variable; a secret removed or renamed during rotation.","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"],"exampleFix":"# before\nnode src/index.mjs\n# after\nWECOM_BOT_ID='xxx' WECOM_BOT_SECRET='yyy' CODEWHALE_RUNTIME_TOKEN='zzz' node src/index.mjs","handlingStrategy":"validation","validationCode":"for (const name of ['WECOM_BOT_ID', 'WECOM_BOT_SECRET', 'CODEWHALE_RUNTIME_TOKEN']) {\n  if (!process.env[name]?.trim()) {\n    console.error(`${name} is required`);\n    process.exit(2);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  startBridge();\n} catch (error) {\n  if (/is required$/.test(error.message)) {\n    console.error(`Missing environment variable: ${error.message}`);\n    process.exit(2);\n  }\n  throw error;\n}","preventionTips":["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"],"tags":["environment","config","validation","wecom-bridge"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}