{"record":{"id":"604c777e62e64e2a","repo":"CherryHQ/cherry-studio","slug":"invalid-arguments-for-glob-parsed-error","errorCode":null,"errorMessage":"Invalid arguments for glob: ${parsed.error}","messagePattern":"Invalid arguments for glob: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"src/main/ai/mcp/servers/filesystem/tools/glob.ts","lineNumber":39,"sourceCode":"\n- Supports glob patterns like \"**/*.js\" or \"src/**/*.ts\"\n- Returns matching absolute file paths sorted by modification time (newest first)\n- Use this when you need to find files by name patterns\n- Patterns without \"/\" (e.g., \"*.txt\") match files at ANY depth in the directory tree\n- Patterns with \"/\" (e.g., \"src/*.ts\") match relative to the search path\n- Pattern syntax: * (any chars), ** (any path), {a,b} (alternatives), ? (single char)\n- Results are limited to 100 files\n- The path parameter must resolve within the configured workspace root if specified\n- If path is not specified, defaults to the base directory\n- IMPORTANT: Omit the path field for the default directory (don't use \"undefined\" or \"null\")`,\n  inputSchema: z.toJSONSchema(GlobToolSchema)\n}\n\n// Handler implementation\nexport async function handleGlobTool(args: unknown, baseDir: string) {\n  const parsed = GlobToolSchema.safeParse(args)\n  if (!parsed.success) {\n    throw new Error(`Invalid arguments for glob: ${parsed.error}`)\n  }\n\n  const searchPath = parsed.data.path || baseDir\n  const validPath = await validatePath(searchPath, baseDir)\n\n  // Verify the search directory exists\n  try {\n    const stats = await fs.stat(validPath)\n    if (!stats.isDirectory()) {\n      throw new Error(`Path is not a directory: ${validPath}`)\n    }\n  } catch (error: unknown) {\n    if (error && typeof error === 'object' && 'code' in error && error.code === 'ENOENT') {\n      throw new Error(`Directory not found: ${validPath}`)\n    }\n    throw error\n  }\n","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/CherryHQ/cherry-studio/blob/726446b54cd69ffe51a276638672f6d95ca0768c/src/main/ai/mcp/servers/filesystem/tools/glob.ts#L21-L57","documentation":"Zod safeParse on the glob tool's arguments failed. GlobToolSchema requires a string `pattern` and accepts an optional string `path`. parsed.error is a ZodError describing which field failed. Returned as an isError tool result by the server-level catch.","triggerScenarios":"The arguments object omits pattern, sends pattern as a non-string, or sends path as a non-string. An empty-string pattern passes zod (the empty check happens later at error 314).","commonSituations":"A model calling glob with only a path and no pattern; a client sending pattern:null; schema drift between the advertised inputSchema and the client's expectations.","solutions":["Provide pattern as a non-empty glob string (e.g. '**/*.ts').","If passing path, ensure it is an absolute string resolving inside the workspace root.","Read parsed.error to identify the failing field."],"exampleFix":"// before\nthrow new Error(`Invalid arguments for glob: ${parsed.error}`)\n\n// after — structured issues\nif (!parsed.success) {\n  const issues = parsed.error.issues.map(i => `${i.path.join('.') || '(root)'}: ${i.message}`).join('; ')\n  throw new Error(`Invalid arguments for glob: ${issues}`)\n}","handlingStrategy":"validation","validationCode":"// Validate glob args on the client.\nfunction isValidGlobArgs(a: unknown): a is { pattern: string; path?: string } {\n  if (typeof a !== 'object' || a === null) return false\n  const o = a as any\n  return typeof o.pattern === 'string' && (o.path === undefined || typeof o.path === 'string')\n}","typeGuard":"function isGlobArgs(a: unknown): a is { pattern: string; path?: string } {\n  return typeof a === 'object' && a !== null && typeof (a as any).pattern === 'string'\n}","tryCatchPattern":null,"preventionTips":["Always send pattern as a non-empty glob string.","Omit path (rather than sending null/undefined as a value) to use the base directory.","Generate client types from z.toJSONSchema(GlobToolSchema).","Run safeParse on the client before dispatching."],"tags":["zod","validation","glob","mcp-tool","filesystem"],"backgroundTag":null,"analyzedSha":"726446b54cd69ffe51a276638672f6d95ca0768c","analyzedAt":"2026-08-12T17:30:37.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}