{"record":{"id":"ddeb11a3079f0904","repo":"Hmbown/CodeWhale","slug":"name-is-required","errorCode":null,"errorMessage":"${name} is required","messagePattern":"(.+?) is required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"integrations/feishu-bridge/src/index.mjs","lineNumber":585,"sourceCode":"          data: body\n        });\n        continue;\n      } catch (error) {\n        canReply = false;\n        console.warn(\"Feishu reply API failed; falling back to message create\", error);\n      }\n    }\n    await createMessage({\n      params: { receive_id_type: \"chat_id\" },\n      data: { ...body, receive_id: chatId }\n    });\n  }\n}\n\nfunction 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\nfunction resolveLarkDomain(domain) {\n  const normalized = String(domain || \"feishu\").toLowerCase();\n  if (normalized === \"lark\") return Lark.Domain?.Lark || \"https://open.larksuite.com\";\n  if (normalized === \"feishu\") return Lark.Domain?.Feishu || \"https://open.feishu.cn\";\n  return domain;\n}\n","sourceCodeStart":567,"sourceCodeEnd":596,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/integrations/feishu-bridge/src/index.mjs#L567-L596","documentation":"requiredEnv() is the Feishu bridge's fail-fast bootstrap guard: the named environment variable must exist and contain non-whitespace, otherwise the process throws `<NAME> is required` instead of starting half-configured. The message names the exact missing variable.","triggerScenarios":"Starting the bridge without the required vars (e.g. FEISHU_APP_ID / FEISHU_APP_SECRET or whichever env the startup path reads); a .env file not loaded in the deployment; a variable set to empty string or spaces.","commonSituations":"New deploy missing secrets; docker/systemd units dropping env; CI running the bridge with stub env; the variable renamed between versions.","solutions":["Set the variable named in the message (export it, add to .env, or inject via secret manager)","Run the bundled validator (integrations/feishu-bridge/scripts/validate-config.mjs) to list all missing values at once","Restart the bridge after setting it"],"exampleFix":"# before - throws: FEISHU_APP_SECRET is required\nnode src/index.mjs\n\n# after\nexport FEISHU_APP_ID=cli_xxxx\nexport FEISHU_APP_SECRET=********\nnode src/index.mjs","handlingStrategy":"validation","validationCode":"// preflight before starting the bridge (names follow requiredEnv usage)\nconst REQUIRED = ['FEISHU_APP_ID', 'FEISHU_APP_SECRET'];\nconst missing = REQUIRED.filter((name) => !(process.env[name] || '').trim());\nif (missing.length) {\n  console.error('missing required env:', missing.join(', '));\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run scripts/validate-config.mjs before every deploy of the bridge","Declare required env in the systemd/docker unit so startup fails loudly","Keep .env.example in sync with requiredEnv() call sites"],"tags":["config","environment","feishu","startup"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}