Repository navigation
Commit d5c31a1
committed
core: let ApplyDiffTool accept what readFile's encoding overload hands back
The previous commit made the tool read bytes and decode fatally. CI did not run green on it: the ubuntu arm
of #1910 checks out the merge ref of this branch onto main (job 129175169868, "HEAD is now at b4a8d6a Merge
c5556a5 into e487cd7"), and main carries src/core/tools/__tests__/applyDiffTool.outsideWorkspace.spec.ts,
which does not exist at this branch's base and therefore cannot be edited here. Its fs double answers
readFile with the string "old\n" at line 143 - the encoding overload - and a strict byte-only read turns that
into a refusal, so 9 of its 30 rows failed with "expected askApproval to be called 1 times, but got 0".
The read now declares readFile's own union - string | Buffer - and treats a string as already decoded by
whoever passed the encoding, because the original bytes are unrecoverable from it. The fatal decode, and so
the refusal, applies where the tool holds bytes, which is every real read: no encoding is passed, so the
byte overload is the one production calls. This keeps the fail-closed decision intact for files while not
forcing every string-returning double in the repo - editFileTool, applyPatchTool, outsideWorkspace - to be
rewritten by a PR that is about undecodable bytes. The trade is stated in the code comment and pinned by a
row that says a pre-decoded file still edits, which is which side gives way.
Measured, all with pinned node v22.23.4 and stdio on file descriptors: on the merge candidate itself
(worktree at b4a8d6a, node_modules junctioned from wt-u2-1911, whose pnpm-lock blob 0fb1d69
differs from the merge ref's 2035d1d - disclosed rather than hidden), applyDiffTool.outsideWorkspace.
spec.ts fails 9 rows under the strict read and passes with this one, together with applyDiffTool.
failureReporting.spec.ts, 50 tests, exit 0; the whole core subtree on that merge candidate is reported
separately below. In 1910's own tree, applyDiffTool.failureReporting with applyPatchTool.execute and
editFileTool passes 80/80; eslint --prune-suppressions --max-warnings=0 exits 0 on both touched files and
its suppressions rewrite was reverted again; prettier --check is clean on both.
Gate: 347 of 500 counted executable lines at base 73931fe with base...head
and --unified=0 on the prettier-formatted tree, against 333 at 303af45 - +14 for the pair of commits -
measured with v22.23.4. The whole core subtree on that merge candidate ran 197 files, 4250 passed and 9
skipped (4259), against CI's 4250 passed and 9 failed under the strict read. Two pushes to #1910 is two review resets under dismiss_stale_reviews_on_push, and
this one could not be folded into the first because the failure only exists in the merge with main.1 parent c5556a5 commit d5c31a1
2 files changed
Lines changed: 24 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
85 | 92 | | |
86 | 93 | | |
87 | 94 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| |||
152 | 154 | | |
153 | 155 | | |
154 | 156 | | |
155 | | - | |
| 157 | + | |
156 | 158 | | |
157 | 159 | | |
158 | 160 | | |
| |||
202 | 204 | | |
203 | 205 | | |
204 | 206 | | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
205 | 219 | | |
206 | 220 | | |
207 | 221 | | |
| |||
0 commit comments