{"record":{"id":"1259299e67eee07b","repo":"Yeachan-Heo/oh-my-codex","slug":"mode-must-be-a-non-empty-string","errorCode":null,"errorMessage":"mode must be a non-empty string","messagePattern":"mode must be a non-empty string","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/mcp/state-paths.ts","lineNumber":136,"sourceCode":"export function validateSessionId(sessionId: unknown): string | undefined {\n  if (sessionId == null) return undefined;\n  if (typeof sessionId !== 'string') {\n    throw new Error('session_id must be a string');\n  }\n  if (!SESSION_ID_PATTERN.test(sessionId)) {\n    throw new Error('session_id must match ^[A-Za-z0-9_-]{1,64}$');\n  }\n  return sessionId;\n}\n\n\nexport function validateStateModeSegment(mode: unknown): string {\n  if (typeof mode !== 'string') {\n    throw new Error('mode must be a string');\n  }\n  const normalized = mode.trim();\n  if (!normalized) {\n    throw new Error('mode must be a non-empty string');\n  }\n  if (normalized.includes('..')) {\n    throw new Error('mode must not contain \"..\"');\n  }\n  if (normalized.includes('/') || normalized.includes('\\\\')) {\n    throw new Error('mode must not contain path separators');\n  }\n  if (!STATE_MODE_SEGMENT_PATTERN.test(normalized)) {\n    throw new Error('mode must match ^[A-Za-z0-9_-]{1,64}$');\n  }\n  return normalized;\n}\n\nexport function getStateFilename(mode: string): string {\n  return `${validateStateModeSegment(mode)}${STATE_FILE_SUFFIX}`;\n}\n\nexport function validateStateFileName(fileName: unknown): string {","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/mcp/state-paths.ts#L118-L154","documentation":"Thrown when the mode string is empty after trimming. Since mode becomes part of a state filename, an empty segment would produce a malformed filename and is rejected.","triggerScenarios":"mode: \"\", mode: \"   \", or mode: \"\\t\" — anything that trims to zero length.","commonSituations":"Optional mode field left as empty string instead of undefined; form input submitted blank; whitespace from templated config values.","solutions":["Pass a meaningful mode like \"team\" or \"default\"","Treat empty as absent: use (mode || \"default\") when building the call","Trim and validate config values at load time"],"exampleFix":"// before\ngetStateFilename(\"   \");\n// after\ngetStateFilename(\"default\");","handlingStrategy":"validation","validationCode":"mode = (mode ?? '').toString().trim() || 'default';","typeGuard":"function isNonEmptyMode(v: string): boolean { return v.trim().length > 0; }","tryCatchPattern":null,"preventionTips":["Treat blank strings as absent and fall back to a named default","Trim config values once at load"],"tags":["validation","state","mcp"],"backgroundTag":"empty-string-argument","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}