{"record":{"id":"ddeb11a3079f0904","repo":"Hmbown/CodeWhale","slug":"name-is-required","errorCode":null,"errorMessage":"${name} is required","messagePattern":"(.+?) is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"integrations/feishu-bridge/src/index.mjs","lineNumber":576,"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":558,"sourceCodeEnd":587,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/integrations/feishu-bridge/src/index.mjs#L558-L587","documentation":"The Feishu bridge validates its runtime configuration at startup via requiredEnv, which reads process.env[name] and throws if the value is missing or blank (whitespace-only). This fail-fast guard ensures the bridge never starts with an incomplete configuration, since a missing token or secret would only surface later as failed API calls. The thrown message names the exact environment variable that is absent.","triggerScenarios":"Calling requiredEnv('X') when process.env.X is undefined, an empty string, or contains only whitespace. Happens at bridge startup for variables like APP_ID, APP_SECRET, etc.","commonSituations":"Developer runs the bridge without sourcing a .env file, deploys to a host where the secret was never set, or exports the variable with only spaces by accident; also common in Docker/CI where the env mapping was forgotten.","solutions":["Set the named environment variable (e.g. export APP_SECRET=... or add it to your deployment env/secret store) and restart the bridge.","If using a .env file, confirm it is actually loaded by the process (dotenv import, docker --env-file, systemd EnvironmentFile).","Check for typos between the variable name in the error and what you exported (exact, case-sensitive match)."],"exampleFix":"// before\nnode integrations/feishu-bridge/src/index.mjs\n// Error: FEISHU_APP_SECRET is required\n\n// after\nexport FEISHU_APP_SECRET=\"xxxx\"\nnode integrations/feishu-bridge/src/index.mjs","handlingStrategy":"validation","validationCode":"function hasEnv(name) {\n  const v = process.env[name];\n  return typeof v === \"string\" && v.trim().length > 0;\n}\nif (!hasEnv(\"FEISHU_APP_SECRET\")) {\n  throw new Error(\"Set FEISHU_APP_SECRET before starting the bridge\");\n}","typeGuard":"const isNonEmptyString = (v) => typeof v === \"string\" && v.trim().length > 0;","tryCatchPattern":"try {\n  startBridge();\n} catch (err) {\n  if (err instanceof Error && err.message.endsWith(\"is required\")) {\n    console.error(`Missing configuration: ${err.message}. Check your env/.env setup.`);\n    process.exit(1);\n  }\n  throw err;\n}","preventionTips":["Keep a .env.example listing every required variable and validate all of them at boot.","Use a startup preflight that asserts each required env var before doing any network work.","In CI/CD, add an environment smoke test that fails fast when secrets are missing."],"tags":["env","configuration","startup"],"backgroundTag":"missing-env-var","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}