{"record":{"id":"ef0ed1f5700fe4ff","repo":"Yeachan-Heo/oh-my-codex","slug":"target-is-required","errorCode":null,"errorMessage":"`target` is required","messagePattern":"`target` is required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cli/tmux-hook.ts","lineNumber":119,"sourceCode":"function tmuxHookStatePath(cwd = process.cwd()): string {\n  return join(omxDir(cwd), 'state', 'tmux-hook-state.json');\n}\n\nfunction tmuxHookLogPath(cwd = process.cwd()): string {\n  return join(omxDir(cwd), 'logs', `tmux-hook-${new Date().toISOString().split('T')[0]}.jsonl`);\n}\n\nfunction parseConfig(raw: unknown): TmuxHookConfig {\n  if (!raw || typeof raw !== 'object') {\n    throw new Error('tmux-hook config must be a JSON object');\n  }\n  const parsed = raw as Record<string, unknown>;\n  if (parsed.enabled !== true && parsed.enabled !== false) {\n    throw new Error('`enabled` must be boolean');\n  }\n  const target = parsed.target;\n  if (!target || typeof target !== 'object') {\n    throw new Error('`target` is required');\n  }\n  const targetObj = target as Record<string, unknown>;\n  if (targetObj.type !== 'session' && targetObj.type !== 'pane') {\n    throw new Error('`target.type` must be \"session\" or \"pane\"');\n  }\n  if (typeof targetObj.value !== 'string' || targetObj.value.trim() === '') {\n    throw new Error('`target.value` must be a non-empty string');\n  }\n\n  const allowedModes = parsed.allowed_modes;\n  if (!Array.isArray(allowedModes) || allowedModes.length === 0 || allowedModes.some(v => typeof v !== 'string')) {\n    throw new Error('`allowed_modes` must be a non-empty string array');\n  }\n\n  const cooldown = parsed.cooldown_ms;\n  const maxInjections = parsed.max_injections_per_session;\n  if (typeof cooldown !== 'number' || cooldown < 0 || !Number.isFinite(cooldown)) {\n    throw new Error('`cooldown_ms` must be a non-negative number');","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/cli/tmux-hook.ts#L101-L137","documentation":"The tmux-hook config lacks a valid `target` object, which tells the hook which tmux session/pane to inject into. It must be present, an object (not null/array/string), to pass validation.","triggerScenarios":"Config omits `target`, sets it to null, a string, or an array. Any falsy or non-object value triggers this before type/value checks run.","commonSituations":"Minimal configs copied from docs that only set enabled; refactors that renamed the key (e.g. session instead of target).","solutions":["Add \"target\": {\"type\": \"session\"|\"pane\", \"value\": \"...\"}","Regenerate the config with omx tmux-hook init and edit values","Check the schema in the docs for required keys"],"exampleFix":"// before\n{\"enabled\": true}\n// after\n{\"enabled\": true, \"target\": {\"type\": \"session\", \"value\": \"omx\"}}","handlingStrategy":"type-guard","validationCode":"const ok = cfg.target && typeof cfg.target === 'object' && !Array.isArray(cfg.target);\nif (!ok) throw new Error('target object required');","typeGuard":"function hasTarget(v: unknown): v is { target: Record<string, unknown> } {\n  return typeof v === 'object' && v !== null && typeof (v as any).target === 'object' && (v as any).target !== null;\n}","tryCatchPattern":"try { await loadConfig(); } catch (e) { if (e instanceof Error && e.message.includes('`target`')) { addTargetAndRetry(); } }","preventionTips":["Always scaffold with omx tmux-hook init then edit incrementally","Keep required keys in a checklist when hand-writing config"],"tags":["config","validation","required-field","tmux-hook"],"backgroundTag":"config-schema-validation-failed","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}