Repository navigation
Conversation
|
👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated. Missing sections:
Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle. |
3 similar comments
|
👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated. Missing sections:
Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle. |
|
👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated. Missing sections:
Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle. |
|
👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated. Missing sections:
Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle. |
21717fc to
f38123b
Compare
|
Rebased onto main Conflicts: none, clean rebase. No behaviour was changed. Gates run locally on changed files only: Please review the rebase. A maintainer push makes the maintainer the last pusher, so under the repo's last-push rule a second approver is needed. Reply if anything looks wrong. |
Design Review (Fable 5, fork) — ✅ PASSDesign-level review of The change matches its description exactly: a real bound-at-the-wrong-end defect on a failure path, fixed at the read with the character contract and OSError behavior preserved, pinned by a test that asserts the absence of the whole-file read. The changed branch runs in CI unit tests on every platform, so the "Manual verification: N/A" claim covers nothing CI misses. No design-level findings survive. Design-Verdict: PASS A child-controlled unbounded read, bounded at the read itself; contract, failure behavior, and response shape preserved — root-cause fix, proportionate, trivially reversible. [DESIGN-REVIEWED] f38123b |
GPT 5.6 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Opus 4.8 Review (fork) — ✅ no blocking findingsReviewed |
First Principles Review (Fable 5, fork) — ✅ PASSPremise-level review of All checks done. Here is the review. First-Principles-Verdict: PASS Nothing to check. What this change shipsInventory (3 items)Intent: stop a failed dev-server launch from loading the child's entire log just to show its last 800 characters — a FIX.
Evidence checked against the base tree: the unbounded read exists verbatim at [FIRST-PRINCIPLES-REVIEWED] f38123b |
|
Kiro Crew [operator: chenmingwei23#de330d0c] Triaged as solvable and claimed for the drive-to-green pipeline. No conflict and no blocking review verdict. The only real failure is PR Hygiene, The Pattern harvest section must contain a "Rule candidate:" or That is a PR-body requirement, not a code defect. The fix is to add one such line No code change is expected. Content security scan passed with no findings. |
|
Thank you @leonlaiyc for this fix. #14949, which carries this change (bounding the design-tweak startup log reads), has now been merged. Closing this as resolved by #14949. 🙏 |
|
@leonlaiyc quick follow-up: your work here landed on |
Problem / Motivation
When an owned project's dev server exits during the 45-second startup window,
Design Tweak reports the failure with the last 800 characters of the server's
log. It obtained them by loading the whole file and slicing:
The size of that read is chosen by the child process, not by the backend.
Why it matters
A dev server can emit an arbitrarily large log inside that 45-second window — a
build loop, a stack-trace flood, a dependency resolver in a retry cycle. Because
the failure path reads the file in full before discarding all but the last 800
characters, a noisy child turns an ordinary launch failure into backend memory
exhaustion.
The bad case is reached precisely when something has already gone wrong, so the
diagnostic path is at its least robust exactly when it is needed.
What changed (motivation → approach → change)
Symptom — the startup failure path at
server.py:739loads an entirechild-controlled log to produce an 800-character diagnostic.
Root cause — the read is unbounded because the bound was applied after
reading, as a slice. The 800-character contract was expressed at the wrong end
of the operation.
Change — extract
_read_dev_log_tail(), which seeks to the end of the fileand reads only the bytes the diagnostic can need, then decodes that window:
_DEV_LOG_TAIL_BYTES = _DEV_LOG_TAIL_CHARS * 4, because UTF-8 encodes acharacter in at most four bytes. The byte bound therefore cannot cut the
character contract short, while the child no longer chooses the read size.
errors="replace"on the window, so a multibyte characterstraddling the seek boundary degrades to a replacement character instead of
raising.
[-_DEV_LOG_TAIL_CHARS:]keeps the existing 800-character contractexact after decode.
OSErrorstill yields"", preserving the previous behaviour when the logcannot be read at all.
The response shape and the 800-character diagnostic are unchanged; only the
amount read from disk is bounded.
Tests
test/test_design_tweak_devproc.py::test_process_exit_reads_only_a_bounded_log_tail— writes a large payload ending in 900 multibyte characters, then patches
Path.read_textto raiseAssertionErrorif the dev log is ever read whole.That inversion is what makes the test meaningful: it pins the absence of the
unbounded read rather than merely observing an output that a whole-file read
would also produce. It then asserts the returned tail equals the last
_DEV_LOG_TAIL_CHARSof the payload, so the multibyte boundary is exercisedrather than assumed.
Red-before: the regression fails on
Path.read_text()atserver.py:739without the production change.
Validation at this exact head (
21717fcbf), the focused suite re-run to confirmit still holds:
test/test_design_tweak_devproc.pygreen (53 passed, 3 platformskips); repository-scoped Black gate clean;
isortandflake8clean on bothtouched files; isolated mypy on
server.pyclean; subprocess-encoding gate,feature-map gate and brand gate clean;
git diff --checkclean.Manual verification
N/A — unit coverage sufficient. Reproducing the unbounded read by hand means
driving a real dev server into emitting a multi-gigabyte log; the regression
asserts the whole-file read never happens, which is the property at issue and is
checked directly rather than inferred from memory behaviour.
Related Issues
No linked issue.
Pattern harvest
Review prompt: inspect other diagnostic-tail call sites for whole-file reads
followed by a slice, especially child-process logs whose producer controls file
size.
Checklist
feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
🤖 Generated with Claude Code