{"record":{"id":"221b60404904f003","repo":"slopus/happy","slug":"invalid-window-name-params-window","errorCode":null,"errorMessage":"Invalid window name: \"${params.window}\"","messagePattern":"Invalid window name: \"(.+?)\"","errorType":"validation","errorClass":"TmuxSessionIdentifierError","httpStatus":null,"severity":"error","filePath":"packages/happy-cli/src/utils/tmux.ts","lineNumber":1035,"sourceCode":"        };\n    }\n}\n\n/**\n * Build a tmux session identifier with validation\n */\nexport function buildTmuxSessionIdentifier(params: {\n    session: string;\n    window?: string;\n    pane?: string;\n}): { success: boolean; identifier?: string; error?: string } {\n    try {\n        if (!params.session || !/^[a-zA-Z0-9._-]+$/.test(params.session)) {\n            throw new TmuxSessionIdentifierError(`Invalid session name: \"${params.session}\"`);\n        }\n\n        if (params.window && !/^[a-zA-Z0-9._-]+$/.test(params.window)) {\n            throw new TmuxSessionIdentifierError(`Invalid window name: \"${params.window}\"`);\n        }\n\n        if (params.pane && !/^[0-9]+$/.test(params.pane)) {\n            throw new TmuxSessionIdentifierError(`Invalid pane identifier: \"${params.pane}\"`);\n        }\n\n        const identifier: TmuxSessionIdentifier = params;\n        return {\n            success: true,\n            identifier: formatTmuxSessionIdentifier(identifier)\n        };\n    } catch (error) {\n        return {\n            success: false,\n            error: error instanceof Error ? error.message : 'Unknown error'\n        };\n    }\n}","sourceCodeStart":1017,"sourceCodeEnd":1053,"githubUrl":"https://github.com/slopus/happy/blob/b824cd0a4681d41af631a8e422a813873e4455b0/packages/happy-cli/src/utils/tmux.ts#L1017-L1053","documentation":"Same validator as the session check: when params.window is provided it must match /^[a-zA-Z0-9._-]+$/. An empty or invalid window string (spaces, ':', '*', etc.) throws TmuxSessionIdentifierError to prevent malformed tmux target strings.","triggerScenarios":"Calling the validator with a window value like 'win dow', 'win:0', '', or a glob such as '*'. Note the check is skipped when window is undefined — only present-but-invalid values throw.","commonSituations":"Constructing targets from user input containing spaces; joining 'session:window' into one field and having part land in window; template placeholders not substituted (e.g. '${window}').","solutions":["Sanitize the window name with .replace(/[^a-zA-Z0-9._-]/g, '-').","Omit params.window entirely if you do not mean to target a window (undefined passes validation).","Pre-validate with /^[a-zA-Z0-9._-]+$/ before the call.","Split 'session:window' strings properly instead of putting the combined value in window."],"exampleFix":"// before\nvalidateIdentifier({ session: 'dev', window: 'main win' });\n// after\nvalidateIdentifier({ session: 'dev', window: 'main-win' });","handlingStrategy":"validation","validationCode":"function assertValidWindow(w) {\n  if (w !== undefined && !/^[a-zA-Z0-9._-]+$/.test(w)) {\n    throw new Error(`Invalid window name: ${JSON.stringify(w)}`);\n  }\n}\nassertValidWindow(params.window);","typeGuard":"function isValidWindowName(w) {\n  return w === undefined || (typeof w === 'string' && /^[a-zA-Z0-9._-]+$/.test(w));\n}","tryCatchPattern":"try {\n  const res = validateIdentifier({ ...params, window: sanitizedWindow });\n} catch (e) {\n  if (e instanceof TmuxSessionIdentifierError && /window/.test(e.message)) {\n    return { success: false, error: 'Window names may only contain letters, digits, dot, underscore, dash' };\n  }\n  throw e;\n}","preventionTips":["Sanitize window names with .replace(/[^a-zA-Z0-9._-]/g, '-').","Leave window undefined rather than passing an empty string.","Do not embed tmux target syntax (':', '*') in the window field.","Trim whitespace from user input before validation."],"tags":["tmux","validation","input-validation"],"backgroundTag":"invalid-window-name","analyzedSha":"b824cd0a4681d41af631a8e422a813873e4455b0","analyzedAt":"2026-08-31T23:12:36.205Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}