{"record":{"id":"12c4c30cddfef8d2","repo":"slopus/happy","slug":"invalid-pane-identifier-params-pane","errorCode":null,"errorMessage":"Invalid pane identifier: \"${params.pane}\"","messagePattern":"Invalid pane identifier: \"(.+?)\"","errorType":"validation","errorClass":"TmuxSessionIdentifierError","httpStatus":null,"severity":"error","filePath":"packages/happy-cli/src/utils/tmux.ts","lineNumber":1039,"sourceCode":"/**\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":1021,"sourceCodeEnd":1053,"githubUrl":"https://github.com/slopus/happy/blob/b824cd0a4681d41af631a8e422a813873e4455b0/packages/happy-cli/src/utils/tmux.ts#L1021-L1053","documentation":"When params.pane is provided, the validator requires it to be all digits (/^[0-9]+$/) because tmux pane indices are numeric. Non-numeric pane values throw TmuxSessionIdentifierError.","triggerScenarios":"Calling the validator with pane values like '0%', '%0', 'a', '1.0', or '0 ' — anything present but not purely digits. Omitting pane (undefined) skips the check.","commonSituations":"Copying tmux target strings like '%3' (pane IDs use a % prefix in tmux display) into the pane field; passing '0.0'; string coercion of a float index; user input with whitespace.","solutions":["Pass only the numeric index: pane: '0', not '%0'.","Strip non-digits: pane.replace(/[^0-9]/g, '').","If you have a tmux pane id (e.g. '%3'), resolve it to an index first via display-message -p '#{pane_index}'.","Omit the pane field to target the whole window instead."],"exampleFix":"// before\nvalidateIdentifier({ session: 'dev', window: 'main', pane: '%0' });\n// after\nvalidateIdentifier({ session: 'dev', window: 'main', pane: '0' });","handlingStrategy":"validation","validationCode":"function assertValidPane(p) {\n  if (p !== undefined && !/^[0-9]+$/.test(p)) {\n    throw new Error(`Pane must be a numeric index, got: ${JSON.stringify(p)}`);\n  }\n}\nassertValidPane(params.pane);","typeGuard":"function isValidPaneIndex(p) {\n  return p === undefined || (typeof p === 'string' && /^[0-9]+$/.test(p));\n}","tryCatchPattern":"try {\n  const res = validateIdentifier({ ...params, pane: paneIndex });\n} catch (e) {\n  if (e instanceof TmuxSessionIdentifierError && /pane/.test(e.message)) {\n    return { success: false, error: 'Pane must be a numeric index (e.g. \"0\")' };\n  }\n  throw e;\n}","preventionTips":["Convert pane to a plain index string: String(paneIndex), never '%N' pane ids.","Trim and strip '%' or other prefixes before passing.","Store pane as a number in your own types and coerce at the boundary.","Leave pane undefined when targeting the whole window."],"tags":["tmux","validation","input-validation"],"backgroundTag":"invalid-pane-identifier","analyzedSha":"b824cd0a4681d41af631a8e422a813873e4455b0","analyzedAt":"2026-08-31T23:12:36.205Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}