{"record":{"id":"9adb49720df11773","repo":"slopus/happy","slug":"invalid-session-name-result-session-only-al","errorCode":null,"errorMessage":"Invalid session name: \"${result.session}\". Only alphanumeric characters, dots, hyphens, and underscores are allowed.","messagePattern":"Invalid session name: \"(.+?)\"\\. Only alphanumeric characters, dots, hyphens, and underscores are allowed\\.","errorType":"validation","errorClass":"TmuxSessionIdentifierError","httpStatus":null,"severity":"error","filePath":"packages/happy-cli/src/utils/tmux.ts","lineNumber":140,"sourceCode":"// Helper to parse tmux session identifier from string with validation\nexport function parseTmuxSessionIdentifier(identifier: string): TmuxSessionIdentifier {\n    if (!identifier || typeof identifier !== 'string') {\n        throw new TmuxSessionIdentifierError('Session identifier must be a non-empty string');\n    }\n\n    // Format: session:window or session:window.pane or just session\n    const parts = identifier.split(':');\n    if (parts.length === 0 || !parts[0]) {\n        throw new TmuxSessionIdentifierError('Invalid session identifier: missing session name');\n    }\n\n    const result: TmuxSessionIdentifier = {\n        session: parts[0].trim()\n    };\n\n    // Validate session name (tmux has restrictions on session names)\n    if (!/^[a-zA-Z0-9._-]+$/.test(result.session)) {\n        throw new TmuxSessionIdentifierError(`Invalid session name: \"${result.session}\". Only alphanumeric characters, dots, hyphens, and underscores are allowed.`);\n    }\n\n    if (parts.length > 1) {\n        const windowAndPane = parts[1].split('.');\n        result.window = windowAndPane[0]?.trim();\n\n        if (result.window && !/^[a-zA-Z0-9._-]+$/.test(result.window)) {\n            throw new TmuxSessionIdentifierError(`Invalid window name: \"${result.window}\". Only alphanumeric characters, dots, hyphens, and underscores are allowed.`);\n        }\n\n        if (windowAndPane.length > 1) {\n            result.pane = windowAndPane[1]?.trim();\n            if (result.pane && !/^[0-9]+$/.test(result.pane)) {\n                throw new TmuxSessionIdentifierError(`Invalid pane identifier: \"${result.pane}\". Only numeric values are allowed.`);\n            }\n        }\n    }\n","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/slopus/happy/blob/b824cd0a4681d41af631a8e422a813873e4455b0/packages/happy-cli/src/utils/tmux.ts#L122-L158","documentation":"tmux restricts session names to a safe charset; parseTmuxSessionIdentifier enforces /^[a-zA-Z0-9._-]+$/ on the parsed session segment and throws this TmuxSessionIdentifierError when the name contains spaces, colons, or other special characters. This prevents commands built from the identifier being misinterpreted or failing inside tmux.","triggerScenarios":"Parsing an identifier whose session name contains illegal characters, e.g. 'my session', 'happy:dev:extra', 'project$', or a path-like name 'a/b'.","commonSituations":"Users naming tmux sessions with spaces; deriving the session name from a directory path or branch name with slashes; pasting a full tmux target containing extra colons; machine/hostnames with underscores-plus-unicode in the name.","solutions":["Rename the tmux session to use only alphanumerics, dots, hyphens, underscores (tmux rename-session).","Sanitize the name before building the identifier: replace invalid chars with '-' or '_'.","Use formatTmuxSessionIdentifier with an already-validated session value.","Catch TmuxSessionIdentifierError and prompt the user for a valid name."],"exampleFix":"// before\nparseTmuxSessionIdentifier('my project:0.0'); // throws (space)\n// after\nconst session = rawName.replace(/[^a-zA-Z0-9._-]/g, '_');\nparseTmuxSessionIdentifier(`${session}:0.0`);","handlingStrategy":"validation","validationCode":"const SAFE = /^[a-zA-Z0-9._-]+$/;\nif (!SAFE.test(sessionName)) {\n  throw new Error(`Session name '${sessionName}' must match [a-zA-Z0-9._-]+`);\n}\nparseTmuxSessionIdentifier(`${sessionName}:0.0`);","typeGuard":"function isSafeTmuxName(name: string): boolean {\n  return /^[a-zA-Z0-9._-]+$/.test(name);\n}","tryCatchPattern":"try {\n  return parseTmuxSessionIdentifier(identifier);\n} catch (err) {\n  if (err instanceof TmuxSessionIdentifierError && /session name/.test(err.message)) {\n    return parseTmuxSessionIdentifier(`${sanitize(raw)}:0.0`);\n  }\n  throw err;\n}","preventionTips":["Sanitize names derived from directories, branches, or hostnames before use.","Never put spaces in tmux session names you feed to tooling.","Adopt a project naming convention matching [a-zA-Z0-9._-]."],"tags":["tmux","validation","naming"],"backgroundTag":"invalid-tmux-session-identifier","analyzedSha":"b824cd0a4681d41af631a8e422a813873e4455b0","analyzedAt":"2026-08-31T23:12:36.205Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}