{"record":{"id":"19a6bbe416e81444","repo":"Yeachan-Heo/oh-my-codex","slug":"sendtoworker-text-must-be-non-empty","errorCode":null,"errorMessage":"sendToWorker: text must be non-empty","messagePattern":"sendToWorker: text must be non-empty","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/team/tmux-session.ts","lineNumber":3741,"sourceCode":"  runTmux(['send-keys', '-t', secondTarget, 'Enter']);\n  return true;\n}\n\nexport const normalizeTmuxCapture = sharedNormalizeTmuxCapture;\n\nfunction normalizeWorkerTriggerForDraftMatch(value: string | null | undefined): string {\n  // Codex/tmux can wrap long path-like trigger text after a hyphen, e.g.\n  // `worker-\\n  1/inbox.md`. Treat those visual wraps as the original token so\n  // delivery verification does not mistake an unsent draft for consumed input.\n  return normalizeTmuxCapture(value ?? '').replace(/-\\s+/g, '-');\n}\n\nfunction assertWorkerTriggerText(text: string): void {\n  if (text.length >= 200) {\n    throw new Error('sendToWorker: text must be < 200 characters');\n  }\n  if (text.trim().length === 0) {\n    throw new Error('sendToWorker: text must be non-empty');\n  }\n  if (text.includes(INJECTION_MARKER)) {\n    throw new Error('sendToWorker: injection marker is not allowed');\n  }\n}\n\nexport function sendToWorkerStdin(\n  stdin: Pick<NodeJS.WritableStream, 'write' | 'writable'> | null | undefined,\n  text: string,\n): void {\n  assertWorkerTriggerText(text);\n  if (!stdin || !stdin.writable) {\n    throw new Error('sendToWorkerStdin: stdin is not writable');\n  }\n  stdin.write(`${text}\\n`);\n}\n\n// Send SHORT text (<200 chars) to worker via tmux send-keys","sourceCodeStart":3723,"sourceCodeEnd":3759,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/team/tmux-session.ts#L3723-L3759","documentation":"Guard inside assertWorkerTriggerText: the trigger text, after trimming, must contain at least one non-whitespace character. Sending only whitespace would press keys that produce no actionable input, leaving the worker pane in an ambiguous state, so it is rejected before any tmux call is made.","triggerScenarios":"Calling sendToWorker / sendToWorkerStdin with '', '   ', '\\n\\t', or any string that is whitespace-only — often from an unvalidated config value, an empty template interpolation, or a variable that was never set.","commonSituations":"Environment/config variable for the trigger is unset so it interpolates to ''; template produces empty string; loop iteration yields undefined coerced to ' '.","solutions":["Default the trigger text: `const trigger = rawTrigger?.trim() || 'proceed'`","Validate user-supplied trigger config at startup, not at send time","Log the offending value before the call when debugging"],"exampleFix":"// before\nsendToWorkerStdin(worker.stdin, process.env.WORKER_TRIGGER ?? '');\n\n// after\nconst trigger = (process.env.WORKER_TRIGGER ?? '').trim();\nif (!trigger) throw new Error('WORKER_TRIGGER must be set to non-empty text');\nsendToWorkerStdin(worker.stdin, trigger);","handlingStrategy":"validation","validationCode":"if (!trigger || trigger.trim().length === 0) throw new Error('trigger text required');","typeGuard":"function isNonEmptyTrigger(text: string): boolean { return typeof text === 'string' && text.trim().length > 0; }","tryCatchPattern":null,"preventionTips":["Default empty triggers to a sensible constant","Fail fast on empty config values at startup"],"tags":["validation","empty-input","tmux","send-keys"],"backgroundTag":"empty-input-validation","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}