Skip to content

TypeScript project filter reads window paths that are not UTF-8 - #1963

Merged
zlareb1 merged 3 commits into
ClickHouse:mainfrom
KaloyanNaumov:pr/ts-nonutf8-path
Dec 2, 2026
Merged

zlareb1 merged 3 commits into
ClickHouse:mainfrom
KaloyanNaumov:pr/ts-nonutf8-path

Conversation

@KaloyanNaumov

@KaloyanNaumov KaloyanNaumov commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Closes: #1959
Related: #1782

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in a release)

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

A TypeScript pass over an umbrella or a scip_ts_projects list no longer fails when the commit window holds a file name that is not valid UTF-8 outside the TypeScript and JavaScript files; before, the pass exited 1 and the TypeScript watermark did not advance. A TypeScript or JavaScript file whose own name is not UTF-8 still fails in the converter, as before #1782.

Why

The project filter came with #1782. The harness writes the window's paths with git_paths, which prints a name as the tree stores it (core.quotePath=false), and scip_ts_projects.py read those lists with read_text(encoding="utf-8"). One name with a Latin-1 byte anywhere in the window, of any file type, raised UnicodeDecodeError in filter; filtered=$(…) under set -e exited 1, the worker recorded a harness failure and the watermark stayed, so every later pass failed the same way. Before #1782 the same window passed, because only the TypeScript-glob list was read.

_read_lines now decodes with os.fsdecode, the way Python decodes argv, so a window path compares equal to a member path given on the command line. main writes the selected members with os.fsencode to sys.stdout.buffer, so the filter prints a member whose name is not UTF-8 back byte for byte (scip-typescript decodes its argv lossily, so such a member is still not indexed); under a UTF-8 locale other than C, stdout's strict error handler raised UnicodeEncodeError there.

Scope and risk

scripts/scip_harness/scip_ts_projects.py (_read_lines and the output loop of main) and two tests. For UTF-8 names nothing changes: os.fsdecode gives the same string and os.fsencode the same bytes. The converter's own window list and the merge are not touched; the converter reads only the TypeScript-glob list, as before #1782.

Compatibility, rollout and rollback

  • Wire: none.
  • Operator steps: none. A repository whose TypeScript watermark is stuck on such a window advances on the next pass.
  • Rollback: reverting brings back the failure; nothing is stored.

Tests

  • tests/unit/test_run_typescript_delta_umbrella.py::test_delta_with_a_non_utf8_file_name_in_the_window: a TypeScript edit in packages/app beside a new packages/lib/caf\xe9.md; only packages/app is indexed. On main the harness exits 1 with UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9.
  • tests/unit/test_scip_ts_projects.py::test_filter_reads_and_prints_names_that_are_not_utf8: filter reads a list holding packages/caf\xe9/src/a.ts and prints the member packages/caf\xe9 as the same bytes, with PYTHONIOENCODING=utf-8:strict; has-config and has-shared read a list with a non-UTF-8 name. It fails on main in the read and, with only the read fixed, in the write.
  • Run on the branch cut from main at 3058a5816: test_scip_ts_projects.py, test_run_typescript_delta_umbrella.py, test_run_typescript_delta_projects.py, test_scip_merge_indexes.py, test_code_compiler_tier_runner.py, test_code_scip_extra_producers.py, test_tunable_constants.py and test_public_copy.py, 126 passed. ruff check, ruff format --check, the function-length gate (52, baseline 52) and scripts/gates/mypy_gate.py (0 errors) pass. mypy on scip_ts_projects.py alone reports the same five errors as on main, none on the changed lines. The full unit suite was not run here; CI runs it.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): Claude Code wrote the diff and the tests. Checked: I reviewed the whole diff and its tests; the runs listed under Tests are the agent's.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • Local format, lint, type checks and focused tests pass. The full make test-unit and applicable integration results are reported by CI; a full local run is not required before pushing.
  • Generated files are regenerated in this PR, not by hand: none are affected.
  • A new migration is additive and numbered after the latest on main; no merged migration is edited: no migration.
  • A behaviour change to any file a plugin ships (hooks/, lib/, bin/, skills/, .mcp.json, the Codex plugin-defaults.json) bumps both plugin manifests' version: no plugin file changed.
  • The frontend builds (npm --prefix frontend run build) and its tests pass, if frontend/ changed: it did not.
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes: no page describes how the filter reads its lists.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers; the history goes in this description (tests/unit/test_public_copy.py).
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.

Note

Low Risk
Narrow change to path list I/O in the TypeScript harness helper; UTF-8 paths are unchanged and no auth or persistence logic is touched.

Overview
Fixes TypeScript umbrella/delta passes that exit 1 when the commit window includes any path whose Git tree name is not valid UTF-8 (e.g. a Latin-1 café.md), which previously raised UnicodeDecodeError in the project filter and blocked the watermark.

scip_ts_projects.py now reads changed-path lists with os.fsdecode on raw bytes (matching how argv paths are decoded) instead of UTF-8 read_text, and writes selected members to sys.stdout.buffer via os.fsencode so non-UTF-8 member names round-trip without UnicodeEncodeError under a strict UTF-8 locale. UTF-8-only repos behave the same.

Tests add plumbing to commit non-UTF-8 tree names and assert a delta beside an unrelated non-TS name still indexes only the touched package, plus direct coverage of filter, has-config, and has-shared on lists with Latin-1 bytes.

Reviewed by Cursor Bugbot for commit 28684e7. Bugbot is set up for automated code reviews on this repo. Configure here.

git_paths prints a name as the tree stores it, and scip_ts_projects.py read
the window lists as strict UTF-8. One file name with a Latin-1 byte anywhere
in the window, a Markdown file included, raised UnicodeDecodeError, so the
TypeScript pass exited 1 and the watermark stayed where it was on every pass.

The lists are decoded with os.fsdecode, as Python decodes argv, so a path
compares equal to a member path given on the command line; the selected
members are written back with os.fsencode, byte for byte.

The harness test commits a TypeScript edit beside caf\xe9.md and expects
only the edited member to be indexed; the helper test reads and prints a
member whose name is not UTF-8 with a strict stdout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
@vercel

vercel Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
loom-docs Ready Ready Preview Dec 2, 2026 12:08am UTC
loom-telemetry Ready Ready Preview Dec 2, 2026 12:08am UTC

Request Review

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The byte round-trip and project-filter checks pass. The new harness test fails before running the filter on macOS.

KaloyanNaumov and others added 2 commits December 1, 2026 23:57
The test wrote caf\xe9.md into the working tree, which macOS rejects with
Errno 92 before the filter runs. It now stores the name in a commit built
with hash-object, update-index --cacheinfo, write-tree and commit-tree, so
no file with that name is created and git_paths prints it from the tree as
in production. It still fails on main (UnicodeDecodeError in the filter)
and passes with the fix.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
@KaloyanNaumov

Copy link
Copy Markdown
Contributor Author

Main (e89cc858f) is merged in with no conflicts. The only change since the review is the test above; the code is untouched.

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The harness regression stores the non-UTF-8 path in Git and tests project selection through the normal window. All 35 focused tests passed on macOS.

@zlareb1
zlareb1 merged commit 2c9c072 into ClickHouse:main Dec 2, 2026
77 checks passed
KaloyanNaumov added a commit to KaloyanNaumov/loom that referenced this pull request Dec 2, 2026
With ClickHouse#1963 merged in, scip_ts_projects.py reads the changed-file list as
git writes it, so the incremental harness test no longer needs to stub
`filter` and `has-config`. The non-UTF-8 member name now passes through
both the real filter and the real converter.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
@KaloyanNaumov
KaloyanNaumov deleted the pr/ts-nonutf8-path branch December 2, 2026 09:33
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.

One non-UTF-8 string or file name fails the whole TypeScript member pass

2 participants