Skip to content

fix: preserve literal Git paths for route inference (DEV-158) - #23

Merged
developjik merged 3 commits into
mainfrom
fix/dev158-nul-git-paths
Nov 24, 2026
Merged

developjik merged 3 commits into
mainfrom
fix/dev158-nul-git-paths

Conversation

@developjik

@developjik developjik commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Read NUL-delimited git diff --name-only -z output in both merge-base and direct fallback paths.
  • Keep filename output untrimmed while retaining existing trimmed revision-helper behavior.
  • Add real disposable Git repository regressions for Korean App Router route inference, ASCII, spaces, tabs, newlines, quotes and backslashes, unrelated-history direct fallback, empty diff and missing refs.

Validation

  • New regressions before fix: 3 failed, 2 passed. After fix: all 5 passed.
  • Full suite: 100 tests across 14 files passed, including existing browser tests.
  • Typecheck, production build, and git diff whitespace check passed.
  • Published files verified byte-for-byte against the local validated files.
  • No release, production service mutation, or repository configuration workaround. The new route-inference regression uses actual temporary Git commits with core.quotePath=true; it is not a full CLI/browser route-selection claim.

Refs DEV-158.


Devin Review

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-24T21:16:59.510200Z
We couldn’t complete this review. Comment @codex review to try again.
1b264a0 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 6 potential issues.

Devin Review

Comment thread src/git.ts
const diff = gitOutput(["diff", "--name-only", "-z", "--diff-filter=ACMR", range], options.cwd);
if (diff !== null) {
return { files: splitLines(diff), range };
return { files: splitPaths(diff), range };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 한글 컴포넌트 변경 시 무관한 페이지까지 비교

한글 이름의 React Router 컴포넌트를 수정하면 componentKey가 이름을 빈 문자열로 바꿉니다. 이름이 한글로만 된 다른 컴포넌트도 같은 키를 받아, 변경되지 않은 페이지까지 비교합니다.

Learn more

resolveRoutes는 Git 변경 목록과 React Router에서 발견한 컴포넌트 이름을 함께 전달합니다. parseRouterSource는 JSX의 Component 속성에서 한글 식별자도 읽습니다. matchRouterRoute는 변경된 파일과 라우트 컴포넌트의 이름을 같은 키 함수로 비교하는데, componentKey는 영문자와 숫자만 남깁니다. 기본 Git 인용 설정에서 이전 변경 목록의 한글은 이스케이프된 숫자로 남았지만, 이제 한글 파일명과 한글 컴포넌트 이름이 같은 빈 키로 합쳐집니다.

Example: /settings는 설정, /help는 도움말을 렌더링합니다. src/pages/설정.tsx만 수정하고 자동 비교를 실행하면 /settings만 선택해야 하지만 /help도 함께 선택합니다.

Recommended fix: componentKey에서 유니코드 문자와 숫자를 보존하고, matchRouterRoute에서는 빈 키끼리 일치시키지 마세요. 서로 다른 한글 컴포넌트가 등록된 Git 기반 테스트에서 변경된 컴포넌트의 경로만 선택되는지 확인하세요.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread src/git.ts
Comment on lines +40 to +42
const diff = gitOutput(["diff", "--name-only", "-z", "--diff-filter=ACMR", range], options.cwd);
if (diff !== null) {
return { files: splitLines(diff), range };
return { files: splitPaths(diff), range };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 탭이 들어간 정적 페이지의 잘못된 스크린샷 주소

탭이 들어간 정적 페이지가 변경되면 captureSide는 탭을 URL에 그대로 넣습니다. 브라우저가 탭을 제거해, 비교에서 다른 페이지를 캡처하거나 404가 발생합니다.

Learn more

staticHtmlRoute는 파일명에서 URL 경로를 만들지만 경로 세그먼트를 인코딩하지 않습니다. 이전 Git 출력에는 탭이 이스케이프되고 파일명 전체가 인용되어, 이 정적 페이지가 자동 비교에 선택되지 않았습니다. 이제 resolveRoutes가 탭을 포함한 경로를 선택하고 captureSide가 그대로 탐색 URL을 만듭니다. 브라우저에서 탭을 제거하므로 serveDirectory는 원래 파일명과 다른 경로를 받습니다. 서버는 그 경로에 해당하는 파일이나 기본 페이지를 반환하며, 둘 다 없으면 404를 반환합니다.

Example: pricing/index.html과 team\tupdates/index.html을 수정합니다. 이전 비교는 /pricing만 캡처했지만, 이제 /team%09updates 대신 /teamupdates도 요청합니다. 그 경로와 루트 index.html이 없으면 새 비교 항목은 404로 실패합니다.

Recommended fix: staticHtmlRoute에서 파일명으로부터 얻은 각 세그먼트를 URL 인코딩한 후 결합하세요. 사용자가 명시한 URL이나 이미 해석된 다른 라우터 경로에는 이 인코딩을 적용하지 마세요. 정적 서버와 자동 비교를 연결한 테스트에서 탭을 포함한 실제 HTML이 캡처되는지 확인하세요.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread src/git.ts
.filter((line) => line.length > 0);
function splitPaths(value: string): string[] {
// Git -z emits literal pathnames separated by NUL, never C-quoted lines.
return value.split("\0").filter((path) => path.length > 0);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 역슬래시가 포함된 폴더에서 존재하지 않는 경로 추론

POSIX에서 이름에 역슬래시가 있는 폴더의 파일을 변경하면 inferRoutes가 역슬래시를 폴더 구분자로 바꿉니다. 실제로는 없는 Next.js 페이지가 비교 대상으로 선택됩니다.

Learn more

Git의 NUL 구분 출력은 POSIX 파일명의 리터럴 역슬래시를 그대로 전달합니다. 기존 출력은 해당 파일명을 인용하고 역슬래시를 이스케이프했기 때문에 App Router의 app/ 판별에 걸리지 않았습니다. 이제 inferRoutes가 toPosix로 리터럴 역슬래시를 /로 바꾸고, nextAppRoute는 바뀐 경로를 실제 페이지로 인식합니다. resolveRoutes는 이 경로를 자동 캡처 대상으로 전달합니다.

Example: app\settings라는 단일 폴더 안의 page.tsx를 수정합니다. 실제 app/settings 폴더가 없는데도 /settings가 선택되어 캡처가 실패합니다.

Recommended fix: Git에서 온 경로는 이미 /가 구분자이므로, CLI와 비교 기능에서 Git 경로임을 명시해 경로 추론 중 역슬래시 변환을 생략하세요. 공개 추론 함수가 지원하던 Windows 스타일 입력은 별도로 유지하고, 회귀 테스트에서 리터럴 역슬래시가 새 경로를 만들지 않는지 확인하세요.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread test/git.test.ts
Comment on lines +43 to +52
it('preserves whitespace, quotes, backslashes and line boundaries without trimming', () => {
const f=fixture();
const names=[' leading.tsx','trailing.tsx ','two words.tsx','tab\tname.tsx','line\nbreak.tsx','quote"name.tsx',...(process.platform==='win32'?[]:['back\\slash.tsx'])];
f.add(names);
expect(changedFiles({cwd:f.cwd,baseRef:f.base}).files.sort()).toEqual([...names].sort());
});
it('uses the same lossless parsing for unrelated-history direct fallback', () => {
const f=fixture();
f.git('checkout','--quiet','--orphan','unrelated');
f.add(['app/설정/page.tsx','tabs\tand\nlines.tsx',' trailing ']);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Windows에서 만들 수 없는 회귀 테스트 파일명

Windows 분기는 역슬래시만 제외하지만 탭, 줄바꿈, 큰따옴표가 포함된 파일도 만들 수 없습니다. 직접 비교 대체 경로 테스트에도 같은 제약이 있으므로, Windows에서 유효한 이름으로 공통 동작을 검증하고 나머지는 POSIX에서만 실행하는 편이 좋습니다.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread src/git.ts
try {
return execFileSync("git", args, {
cwd,
encoding: "utf8",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 UTF-8이 아닌 Git 파일명의 바이트 손실

Git은 이름의 원래 바이트를 출력하지만 UTF-8 디코딩은 유효하지 않은 바이트를 �로 바꿉니다. UTF-8만 지원하는 것이 의도라면 파일명 보존 범위를 문서에 명시하는 편이 좋습니다.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread src/git.ts
.filter((line) => line.length > 0);
function splitPaths(value: string): string[] {
// Git -z emits literal pathnames separated by NUL, never C-quoted lines.
return value.split("\0").filter((path) => path.length > 0);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟨 PR 파일명이 터미널의 경로 목록을 변조할 수 있음

검토자가 PR 브랜치에서 proofshot routes를 실행하면 commandRoutes는 파일명을 그대로 출력합니다. PR 작성자가 파일명에 넣은 제어 문자가 터미널에서 해석되어 경로 목록을 숨기거나 덮어쓸 수 있습니다.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

@developjik
developjik merged commit 4b4c74f into main Nov 24, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant