{"record":{"id":"4c0a88b114f5852f","repo":"slopus/happy","slug":"invalid-session-name-params-session","errorCode":null,"errorMessage":"Invalid session name: \"${params.session}\"","messagePattern":"Invalid session name: \"(.+?)\"","errorType":"validation","errorClass":"TmuxSessionIdentifierError","httpStatus":null,"severity":"error","filePath":"packages/happy-cli/src/utils/tmux.ts","lineNumber":1031,"sourceCode":"    } catch (error) {\n        return {\n            valid: false,\n            error: error instanceof Error ? error.message : 'Unknown validation error'\n        };\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,","sourceCodeStart":1013,"sourceCodeEnd":1049,"githubUrl":"https://github.com/slopus/happy/blob/b824cd0a4681d41af631a8e422a813873e4455b0/packages/happy-cli/src/utils/tmux.ts#L1013-L1049","documentation":"This identifier-validation helper (parse/validate entry around tmux.ts:1031) requires params.session to be non-empty and match /^[a-zA-Z0-9._-]+$/. Otherwise it throws TmuxSessionIdentifierError so downstream tmux commands never receive a malformed target.","triggerScenarios":"Calling the validator with params.session empty, undefined, or containing disallowed characters (spaces, ':', '/', etc.), e.g. { session: 'my sess' } or { session: '' }.","commonSituations":"User-supplied session names passed through unvalidated from CLI args or config; reading a session identifier from an env var that is unset; copying a full 'session:window' target into the session field.","solutions":["Pass only the session name portion; move any window into params.window.","Sanitize with name.replace(/[^a-zA-Z0-9._-]/g, '-') before the call.","Check that the source variable is actually defined/non-empty before invoking.","Pre-validate with /^[a-zA-Z0-9._-]+$/ to fail early with your own message."],"exampleFix":"// before\nvalidateIdentifier({ session: 'dev:0' });\n// after\nvalidateIdentifier({ session: 'dev', window: '0' });","handlingStrategy":"validation","validationCode":"function assertValidParams(params) {\n  if (!params?.session || !/^[a-zA-Z0-9._-]+$/.test(params.session)) {\n    throw new Error(`Invalid session: ${JSON.stringify(params?.session)}`);\n  }\n}\nassertValidParams(params);","typeGuard":"function hasValidSession(p) {\n  return typeof p === 'object' && p !== null &&\n    typeof p.session === 'string' && /^[a-zA-Z0-9._-]+$/.test(p.session);\n}","tryCatchPattern":"try {\n  const res = validateIdentifier(params);\n  if (!res.success) return res;\n} catch (e) {\n  if (e instanceof TmuxSessionIdentifierError) {\n    return { success: false, error: e.message };\n  }\n  throw e;\n}","preventionTips":["Split 'session:window' targets into separate fields before validation.","Sanitize user-provided names at the entry point.","Reject empty strings explicitly, not just undefined.","Validate in the UI/CLI layer with the same regex the library uses."],"tags":["tmux","validation","input-validation"],"backgroundTag":"invalid-session-name","analyzedSha":"b824cd0a4681d41af631a8e422a813873e4455b0","analyzedAt":"2026-08-31T23:12:36.205Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}