{"record":{"id":"648dbe5ac4ae7a65","repo":"deepseek-ai/deepseek-harness","slug":"fs-not-text","errorCode":"FS_NOT_TEXT","errorMessage":"cannot read \"${displayPath}\": binary file","messagePattern":"cannot read \"(.+?)\": binary file","errorType":"error_code","errorClass":"FsError","httpStatus":null,"severity":"error","filePath":"packages/e2b/fs-e2b/src/index.ts","lineNumber":55,"sourceCode":"\nfunction normalizeLineEndings(value: string): string {\n  return value.replaceAll('\\r\\n', '\\n')\n}\n\nfunction detectsCrlf(value: string): boolean {\n  const sample = value.slice(0, 4096)\n  const crlf = sample.split('\\r\\n').length - 1\n  const lf = sample.split('\\n').length - 1 - crlf\n  return crlf > lf\n}\n\nfunction restoreLineEndings(value: string, crlf: boolean): string {\n  return crlf ? normalizeLineEndings(value).replaceAll('\\n', '\\r\\n') : value\n}\n\nfunction decodeText(bytes: Uint8Array, displayPath: string, binarySampleBytes: number): string {\n  if (bytes.subarray(0, binarySampleBytes).includes(0)) {\n    throw new FsError(`cannot read \"${displayPath}\": binary file`, 'FS_NOT_TEXT')\n  }\n  try {\n    return new TextDecoder('utf-8', { fatal: true }).decode(bytes)\n  } catch (error: unknown) {\n    throw new FsError(`cannot read \"${displayPath}\": invalid UTF-8 text`, 'FS_NOT_TEXT', { cause: error })\n  }\n}\n\nfunction decodeCanonicalPath(encoded: string): string {\n  if (encoded.length === 0 || !BASE64.test(encoded)) {\n    throw new Error('fs-e2b: canonical path transport returned invalid base64')\n  }\n  const framed = Buffer.from(encoded, 'base64')\n  if (framed.toString('base64') !== encoded\n    || framed.length < 2\n    || framed.at(-1) !== 0\n    || framed.subarray(0, -1).includes(0)) {\n    throw new Error('fs-e2b: canonical path transport returned invalid NUL framing')","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/deepseek-ai/deepseek-harness/blob/b150a551b8d465e31e418e1b2eaf5e79bbb7d28e/packages/e2b/fs-e2b/src/index.ts#L37-L73","documentation":"Text decode guard in decodeText: the file's leading sample bytes contain a NUL byte, so the sandbox file is treated as binary. readText only returns text; binary reads must use readBytes, and the refusal comes through FsError code FS_NOT_TEXT naming the display path.","triggerScenarios":"Thrown at packages/e2b/fs-e2b/src/index.ts:55 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use readBytes for binary files","Read a different, text-format file","If the file should be text, fix whatever wrote binary content to it"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b150a551b8d465e31e418e1b2eaf5e79bbb7d28e","analyzedAt":"2026-08-24T18:12:29.105Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}