{"record":{"id":"3eed63fd8eedf0b4","repo":"Hmbown/CodeWhale","slug":"name-is-required-3eed63","errorCode":null,"errorMessage":"${name} is required","messagePattern":"(.+?) is required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"integrations/telegram-bridge/src/index.mjs","lineNumber":977,"sourceCode":"    signal: options.signal\n  });\n  const payload = await readJsonSafe(response);\n  if (!response.ok || payload?.ok === false) {\n    const error = new Error(\n      payload?.description || `Telegram API request failed (${response.status})`\n    );\n    error.errorCode = payload?.error_code || response.status;\n    error.description = payload?.description || \"\";\n    error.parameters = payload?.parameters || {};\n    throw error;\n  }\n  return payload.result;\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 requiredEnvFirst(...names) {\n  const value = envFirst(process.env, ...names);\n  if (!value) {\n    throw new Error(`${names.join(\" or \")} is required`);\n  }\n  return value;\n}\n\nfunction delay(ms) {\n  return new Promise((resolve) => setTimeout(resolve, ms));\n}\n","sourceCodeStart":959,"sourceCodeEnd":993,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/integrations/telegram-bridge/src/index.mjs#L959-L993","documentation":"requiredEnv(name) reads process.env[name] during bridge startup and throws `${name} is required` when the value is absent or whitespace-only. In the telegram bridge it guards TELEGRAM_BOT_TOKEN (index.mjs:48). The process aborts during config assembly, before any Telegram or runtime traffic occurs.","triggerScenarios":"Starting `node src/index.mjs` without TELEGRAM_BOT_TOKEN exported, or with it set to an empty or whitespace-only string (blank line in .env, `TELEGRAM_BOT_TOKEN=\"\" node ...`).","commonSituations":"Forgot to source the .env file; docker run without -e or --env-file; CI secret not injected into the job; quoting or trailing-space mistake in a systemd Environment= line.","solutions":["Export a real token from @BotFather: `export TELEGRAM_BOT_TOKEN='123456:ABC-DEF...'`","Verify before starting: `printenv TELEGRAM_BOT_TOKEN` should print a non-empty value","For containers/services, add the variable via --env-file or the unit's Environment=, and confirm the file is loaded before config assembly"],"exampleFix":"# before\nnode src/index.mjs   # TELEGRAM_BOT_TOKEN unset\n# after\nTELEGRAM_BOT_TOKEN='123456:ABC-DEF' node src/index.mjs","handlingStrategy":"validation","validationCode":"const botToken = process.env.TELEGRAM_BOT_TOKEN?.trim();\nif (!botToken) {\n  console.error('TELEGRAM_BOT_TOKEN is required — get one from @BotFather');\n  process.exit(2);\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":["Run a required-vars checklist before importing the bridge","Load .env explicitly (dotenv) instead of relying on hand-exported shell vars"],"tags":["environment","config","validation","startup","telegram-bridge"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}