Code review: binary paths containing ` b/` are truncated and misclassified as renames

Abierto Apto para principiantes
#3,936 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@Guihakka2 ya está trabajando en esto.

Desde el 24/11/2026.

  • #3969 de @Guihakka2 — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
74/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
typescript
Área
tooling

Línea de trabajo

Empieza con parseDiffGitHeader en packages/core/diff-paths.ts, donde está la expresión regular para diff --git a/... b/... sin comillas, y luego sigue su uso en parseDiffToFiles en packages/core/diff-files.ts. Ejecuta el fragmento bun repro-diff-path.ts del issue para confirmar la salida incorrecta de icon.png/oldPath, y luego añade tests del parser junto a los tests de diff existentes. Terminado cuando el encabezado binario de rutas iguales produzca path: "assets b/icon.png" sin oldPath y con estado modified, mientras que las rutas entre comillas y los casos reales de rename/copy sigan pasando.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

What happened?

A binary modification under a directory containing the literal sequence b/ is parsed with the wrong file identity and incorrectly classified as a rename. The existing file assets b/icon.png becomes path: "icon.png", with oldPath: "assets b/icon.png b/assets".

I reproduced this by calling the unmodified production parseDiffToFiles with actual git diff output from an isolated repository. A control file at assets/icon.png parses correctly. This verifies the parser; I have not run the browser UI or a packaged Plannotator binary.

Minimal reproduction

From a Plannotator checkout, save this as repro-diff-path.ts and run bun repro-diff-path.ts:

import { parseDiffToFiles } from './packages/core/diff-files';

const patch = [
  'diff --git a/assets b/icon.png b/assets b/icon.png',
  'index a4b2576..e98258d 100644',
  'Binary files a/assets b/icon.png and b/assets b/icon.png differ',
  '',
].join('\n');

console.log(parseDiffToFiles(patch).map(({ path, oldPath, status }) =>
  ({ path, oldPath, status })));

This is real Git output: create and commit a PNG at assets b/icon.png, change its binary bytes, then run git diff --no-ext-diff --no-textconv. Git leaves these space-containing paths unquoted in this header.

Actual result

[{"path":"icon.png","oldPath":"assets b/icon.png b/assets","status":"renamed"}]

Expected result

[{"path":"assets b/icon.png","status":"modified"}]

oldPath should be absent because the file was not renamed.

Source and impact
  • parseDiffGitHeader uses /^diff --git a\/(.+) b\/(.+)$/ for unquoted headers. The first greedy group consumes through the b/ inside the new-side path.
  • parseDiffToFiles has no ---/+++ or rename metadata to fall back to for this binary modification, so it propagates incorrect paths and derives renamed.
  • The code-review app uses this parser for its file list, and listPatchFiles uses it for the server's changed-file set. findPatchFileEntry also uses the same header parser. Downstream file identity/path lookup therefore receives a path that does not name the changed file. These downstream implications are based on source inspection, not a browser reproduction.

A fix should cover unquoted equal-path binary headers containing b/, while preserving quoted paths and genuine rename/copy handling. Simply making the regex non-greedy also needs care: b/ can occur in the old-side path too.

Related reports checked

I searched issues and PRs for the parser name, binary paths, whitespace and diff headers. #628 concerns quoted/non-ASCII headers and is closed; this reproduction uses an unquoted header and still fails on the checked main snapshot.

Plannotator version

Source checkout at 76cbbecf8bfe67ad1c3f8713c0c0907663710fd5 (package.json: 0.29.2). The same parser file was rechecked on main before filing.

OS

Windows. Verification runtime: Node.js v24.22.3 with native TypeScript support and an extension-resolution hook for the repo's extensionless import; Git 2.56.0.windows.2. The Bun snippet above is the equivalent maintainer-facing reproduction; the measured output was obtained with Node calling the original source functions.

Agent

None / standalone source-level reproduction

Where did it happen?

Code review — shared diff parser

Browser

Not used.

Lenguaje dominante
TypeScript
Estrellas
8.7k
Forks
649
Merge medio
14 h 26 min
PR fusionados (30 d)
772

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de backnotprop/plannotator

Todos los issues de backnotprop/plannotator

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.