{"record":{"id":"d98435d929947e3a","repo":"affaan-m/ECC","slug":"invalid-terminal-name-use-a-simple-adapter-name-s","errorCode":null,"errorMessage":"Invalid terminal name; use a simple adapter name such as wezterm.","messagePattern":"Invalid terminal name; use a simple adapter name such as wezterm\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"skills/terminal-opener/scripts/open-terminal.js","lineNumber":42,"sourceCode":"  --standalone       Alias for --recover.\n  --detect           Check whether the selected terminal can be launched.\n  --launch           Explicitly open the terminal (the default only prints a plan).\n  --dry-run          Explicitly print the launch plan without opening a terminal.\n  --json             Emit the plan, capability, or launch result as JSON.\n  --help, -h         Show this help.\n\nAlways pass the executable and arguments as separate entries after --.\nShell command strings are not accepted.\n`;\n}\n\nfunction isAbsolutePath(value) {\n  return path.isAbsolute(value) || path.win32.isAbsolute(value);\n}\n\nfunction validateTerminalName(value) {\n  if (!/^[A-Za-z0-9][A-Za-z0-9_.-]*$/.test(value)) {\n    throw new Error('Invalid terminal name; use a simple adapter name such as wezterm.');\n  }\n}\n\nfunction validateCwd(value) {\n  if (value.includes('\\0')) throw new Error('--cwd must not contain a NUL byte.');\n  if (!isAbsolutePath(value)) throw new Error('--cwd must be an absolute path.');\n}\n\nfunction validateExecutable(value) {\n  if (!value || /[\\0\\r\\n]/.test(value)) {\n    throw new Error('Executable must be a non-empty argv entry without control bytes.');\n  }\n\n  const whitespaceIndex = value.search(/\\s/);\n  const separatorIndexes = [value.indexOf('/'), value.indexOf('\\\\')].filter(index => index >= 0);\n  const firstSeparatorIndex = separatorIndexes.length > 0 ? Math.min(...separatorIndexes) : -1;\n  const resemblesExecutablePath = isAbsolutePath(value)\n    || (firstSeparatorIndex >= 0 && (whitespaceIndex < 0 || firstSeparatorIndex < whitespaceIndex));","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/skills/terminal-opener/scripts/open-terminal.js#L24-L60","documentation":"validateTerminalName requires the terminal adapter name to match ^[A-Za-z0-9][A-Za-z0-9_.-]*$ — it must start alphanumeric and contain only alphanumerics, dots, dashes, and underscores. This blocks path traversal, shell metacharacters, and option injection in the --terminal value. Only 'wezterm' is actually supported (SUPPORTED_TERMINALS), but the name is syntactically validated first.","triggerScenarios":"Passing --terminal (or setting ECC_TERMINAL) to a value that fails the regex: empty string, leading dash/slash/space, or any special character. parseArgs calls validateTerminalName near the end of parsing.","commonSituations":"ECC_TERMINAL accidentally set to an absolute path like /usr/bin/wezterm; passing --terminal 'wez term' with a space; copying a path from another tool; empty value from an env var.","solutions":["Use a plain adapter name such as 'wezterm'.","If ECC_TERMINAL is set wrongly, unset it or set it to 'wezterm'.","Pass only the adapter name, not a path: --terminal wezterm (no slashes, spaces, or leading dashes)."],"exampleFix":"# before\nECC_TERMINAL=/usr/bin/wezterm node open-terminal.js -- echo hi\n\n# after\nunset ECC_TERMINAL\nnode open-terminal.js --terminal wezterm -- echo hi","handlingStrategy":"validation","validationCode":"function isValidTerminalName(value) {\n  return typeof value === 'string' && /^[A-Za-z0-9][A-Za-z0-9_.-]*$/.test(value);\n}\nconst terminal = process.env.ECC_TERMINAL || 'wezterm';\nif (!isValidTerminalName(terminal)) {\n  throw new Error(`Invalid terminal name: ${JSON.stringify(terminal)}`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass the adapter name only (e.g. 'wezterm'), never a path.","Validate ECC_TERMINAL at app startup if it comes from an untrusted source.","Remember only 'wezterm' is actually supported even if the name passes the regex."],"tags":["validation","terminal","argument-parsing","security"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}