{"record":{"id":"007e1c2ebbbac4c7","repo":"deepseek-ai/deepseek-harness","slug":"search-failed-007e1c","errorCode":"SEARCH_FAILED","errorMessage":"grep received malformed ripgrep --json output (a line is not JSON)","messagePattern":"grep received malformed ripgrep --json output \\(a line is not JSON\\)","errorType":"exception","errorClass":"SearchError","httpStatus":null,"severity":"error","filePath":"packages/fs/tool-fs-search/src/grep.ts","lineNumber":140,"sourceCode":" */\nfunction malformedRecord(detail: string, cause?: unknown): SearchError {\n  return new SearchError(`grep received malformed ripgrep --json output (${detail})`, 'SEARCH_FAILED', cause !== undefined ? { cause } : undefined)\n}\n\n/**\n * Parse one `rg --json` NDJSON line into a match, `undefined` for the\n * non-match record types (`begin`/`end`/`context`/`summary`). A line that is\n * not JSON, or a `match` record missing its path / line number / line content,\n * throws {@link SearchError} `SEARCH_FAILED`. A match whose line is not valid\n * UTF-8 (ripgrep sends base64 `bytes` instead of `text`) yields a placeholder\n * preview rather than failing the whole search.\n */\nfunction parseRecord(line: string): GrepMatch | undefined {\n  let parsed: unknown\n  try {\n    parsed = JSON.parse(line)\n  } catch (error: unknown) {\n    throw malformedRecord('a line is not JSON', error)\n  }\n  if (typeof parsed !== 'object' || parsed === null) throw malformedRecord('a record is not an object')\n  const record = parsed as { type?: unknown; data?: unknown }\n  // Non-match record types (begin/end/context/summary — and any future type)\n  // are transport framing, not results: skipped, not malformed.\n  if (record.type !== 'match') return undefined\n  if (typeof record.data !== 'object' || record.data === null) throw malformedRecord('a match record has no data')\n  const data = record.data as { path?: unknown; line_number?: unknown; lines?: unknown }\n  const pathText = typeof data.path === 'object' && data.path !== null ? (data.path as { text?: unknown }).text : undefined\n  if (typeof pathText !== 'string') throw malformedRecord('a match record has no path text')\n  if (typeof data.line_number !== 'number') throw malformedRecord('a match record has no line number')\n  if (typeof data.lines !== 'object' || data.lines === null) throw malformedRecord('a match record has no line content')\n  const lines = data.lines as { text?: unknown; bytes?: unknown }\n  if (typeof lines.text === 'string') {\n    return { path: pathText, lineNumber: data.line_number, line: lines.text.replace(/\\r?\\n$/, '') }\n  }\n  if (typeof lines.bytes === 'string') {\n    return { path: pathText, lineNumber: data.line_number, line: '(line is not valid UTF-8)' }","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/deepseek-ai/deepseek-harness/blob/b150a551b8d465e31e418e1b2eaf5e79bbb7d28e/packages/fs/tool-fs-search/src/grep.ts#L122-L158","documentation":"Error \"grep received malformed ripgrep --json output (a line is not JSON)\" thrown in deepseek-ai/deepseek-harness.","triggerScenarios":"Thrown at packages/fs/tool-fs-search/src/grep.ts:140 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Upgrade or reinstall ripgrep; verify that rg --json output is not intercepted or corrupted."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b150a551b8d465e31e418e1b2eaf5e79bbb7d28e","analyzedAt":"2026-08-24T18:12:29.105Z","schemaVersion":2},"datasetVersion":"2026-08-24T22:17:12.610Z"}