{"record":{"id":"ab0b792939e0e6c5","repo":"dmtrKovalenko/fff","slug":"grepresult-error","errorCode":null,"errorMessage":"grepResult.error","messagePattern":"grepResult\\.error","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/pi-fff/src/index.ts","lineNumber":935,"sourceCode":"      }\n\n      // caseSensitive override flips smartCase off; omitting it keeps smart-case\n      // (case-insensitive when pattern is all lowercase).\n      const smartCase = params.caseSensitive !== true;\n\n      const grepResult = picker.grep(query, {\n        mode,\n        smartCase,\n        maxMatchesPerFile: GREP_MAX_MATCHES_PER_FILE,\n        pageSize,\n        cursor: (params.cursor ? getCursor(params.cursor) : null) ?? null,\n        beforeContext: context,\n        afterContext: context,\n        classifyDefinitions: true,\n        timeBudgetMs: GREP_TIME_BUDGET_MS,\n      });\n\n      if (!grepResult.ok) throw new Error(grepResult.error);\n\n      let result = grepResult.value;\n      let fuzzyNotice: string | null = null;\n\n      // if we hit the timeout do not run the fuzzy fallback\n      // cause it will only consumer more time\n      if (\n        result.items.length === 0 &&\n        !result.nextCursor &&\n        !params.cursor &&\n        mode !== \"regex\"\n      ) {\n        // When the caller pinned a specific file (path has an extension), the\n        // fuzzy fallback broadens across the whole picker — the file may just\n        // be misnamed. For directory constraints (or no path), we keep the\n        // constrained query so the fallback does not leak matches from\n        // excluded / out-of-scope directories.\n        const lastSeg = params.path?.split(/[\\\\/]/).pop() ?? \"\";","sourceCodeStart":917,"sourceCodeEnd":953,"githubUrl":"https://github.com/dmtrKovalenko/fff/blob/7f8537e70f0ea1210f9acbbfc4640141105cdc78/packages/pi-fff/src/index.ts#L917-L953","documentation":"The underlying picker's grep operation returns a result object of shape { ok, error?, value? }; when `ok` is false the tool rethrows the contained error string. This surfaces native (Rust/ripgrep-style) grep failures — bad regex, IO errors, internal panics — as thrown exceptions.","triggerScenarios":"Calling grep with an invalid regex pattern; the picker's file walker failing on unreadable paths; an internal error inside the native search binary; timeout/abort surfacing inside the native call.","commonSituations":"Patterns containing unbalanced parens/brackets or regex metacharacters the engine rejects; searching directories with permission problems; native binary version mismatch.","solutions":["Read the thrown message: if it mentions regex, fix the pattern (escape metacharacters or use literal constraints)","Verify the searched path exists and is readable","Catch the error and fall back to a simpler pattern or the find tool","Rebuild/update the native fff binary if the error indicates an internal/FFI failure"],"exampleFix":"// before\npattern: \"foo(\"\n\n// after\npattern: \"foo\\\\(\" // escape regex metacharacters, or use multiGrep with literal patterns","handlingStrategy":"try-catch","validationCode":"// validate regex before calling\nnew RegExp(pattern); // throws locally on invalid pattern","typeGuard":null,"tryCatchPattern":"try { await grepTool.execute(id, params, signal); } catch (e) { if (String(e).match(/regex|pattern/i)) return simplifiedGrep(params); throw e; }","preventionTips":["Test grep patterns as valid regex before use","Escape regex metacharacters or use multiGrep for literal patterns","Check searched paths exist and are readable"],"tags":["grep","regex","native"],"backgroundTag":"api-error-response","analyzedSha":"7f8537e70f0ea1210f9acbbfc4640141105cdc78","analyzedAt":"2026-09-10T07:26:53.407Z","contentChangedAt":"2026-09-10T07:26:53.407Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}