slopus/happy · error · TmuxSessionIdentifierError
Invalid session name: "${params.session}"
Error message
Invalid session name: "${params.session}" What it means
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.
Source
Thrown at packages/happy-cli/src/utils/tmux.ts:1031
} catch (error) {
return {
valid: false,
error: error instanceof Error ? error.message : 'Unknown validation error'
};
}
}
/**
* Build a tmux session identifier with validation
*/
export function buildTmuxSessionIdentifier(params: {
session: string;
window?: string;
pane?: string;
}): { success: boolean; identifier?: string; error?: string } {
try {
if (!params.session || !/^[a-zA-Z0-9._-]+$/.test(params.session)) {
throw new TmuxSessionIdentifierError(`Invalid session name: "${params.session}"`);
}
if (params.window && !/^[a-zA-Z0-9._-]+$/.test(params.window)) {
throw new TmuxSessionIdentifierError(`Invalid window name: "${params.window}"`);
}
if (params.pane && !/^[0-9]+$/.test(params.pane)) {
throw new TmuxSessionIdentifierError(`Invalid pane identifier: "${params.pane}"`);
}
const identifier: TmuxSessionIdentifier = params;
return {
success: true,
identifier: formatTmuxSessionIdentifier(identifier)
};
} catch (error) {
return {
success: false,View on GitHub (pinned to b824cd0a46)
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.
Example fix
// before
validateIdentifier({ session: 'dev:0' });
// after
validateIdentifier({ session: 'dev', window: '0' }); Defensive patterns
Strategy: validation
Validate before calling
function assertValidParams(params) {
if (!params?.session || !/^[a-zA-Z0-9._-]+$/.test(params.session)) {
throw new Error(`Invalid session: ${JSON.stringify(params?.session)}`);
}
}
assertValidParams(params); Type guard
function hasValidSession(p) {
return typeof p === 'object' && p !== null &&
typeof p.session === 'string' && /^[a-zA-Z0-9._-]+$/.test(p.session);
} Try / catch
try {
const res = validateIdentifier(params);
if (!res.success) return res;
} catch (e) {
if (e instanceof TmuxSessionIdentifierError) {
return { success: false, error: e.message };
}
throw e;
} Prevention
- 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.
When it happens
Trigger: Calling the validator with params.session empty, undefined, or containing disallowed characters (spaces, ':', '/', etc.), e.g. { session: 'my sess' } or { session: '' }.
Common situations: 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.
Related errors
- Session identifier must be a non-empty string
- Invalid session identifier: missing session name
- Invalid session name: "${sessionName}"
- Invalid window name: "${params.window}"
- Invalid pane identifier: "${params.pane}"
AI-assisted analysis of slopus/happy@b824cd0a46 (2026-08-31).
Data as JSON: /api/errors/4c0a88b114f5852f.
Report an issue: GitHub.