Repository navigation
fix(workflows): cap gate show_file line width, not just its line count - #4534
jawwad-ali wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The focused fix correctly addresses the prompt-flooding regression with appropriate test coverage.
Pull request overview
Bounds gate show_file output by truncating oversized lines while preserving ordinary content.
Changes:
- Adds a 500-character per-line cap with a truncation notice.
- Adds regression and unchanged-content tests.
File summaries
| File | Description |
|---|---|
src/specify_cli/workflows/steps/gate/__init__.py |
Implements per-line truncation. |
tests/test_workflows.py |
Tests long-line truncation and short-line preservation. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
mnriem
left a comment
There was a problem hiding this comment.
Please resolve conflicts
`_read_show_file` bounds the number of lines with `MAX_SHOW_FILE_LINES`, but
nothing bounds a single line's length. A file with no newlines -- minified
JSON, a lockfile, a base64 blob, all plausible review material for a gate --
is one line of arbitrary size, so the cap never triggers and the entire file
floods the prompt, which is precisely what the cap exists to prevent.
Reproduced on main:
many short lines : returned 201 lines, total chars=1323 (cap=200)
one long line : returned 1 lines, total chars=400008 <-- unbounded
With the per-line cap:
many short lines : 201 lines, 1323 chars (unchanged)
one long line : 1 lines, 536 chars
short file : ['hello', 'world'] (untouched)
Rebased onto current main (files moved in the workflow/bundler restructure).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
de4ad92 to
879a7e5
Compare
|
@mnriem Conflicts resolved (879a7e5). The fix now lives at Verified: Heads-up: #4529 touches the same module, so whichever merges second may need a trivial rebase. I'll handle it. Rebased as a single commit on current |
|
Please address test & lint errors |
Problem
GateStep._read_show_filebounds the number of lines:but nothing bounds a single line's length. A file with no newlines — minified JSON, a lockfile, a base64 blob, all plausible review material to put in front of an approver — is one line of arbitrary size, so the cap never triggers and the whole file floods the prompt. That is exactly the outcome
MAX_SHOW_FILE_LINESexists to prevent.Reproduction on current
main(c173bf1)The 5,000-line file is correctly clipped to 1,323 characters. The single-line 400 KB file passes through whole.
The content is also rendered inside the gate box one character at a time by
_prompt, so the operator's terminal is buried and the choice prompt is pushed far off screen.Fix
Add a per-line cap alongside the line cap, with a notice in the same style as the existing one:
After the fix:
Verification
upstream/main→ 49 passed with the fix.test_read_show_file_truncates_large_file,test_read_show_file_strips_control_charsandtest_read_show_file_emptyall use short lines and are unaffected — they pass unchanged.uvx ruff@0.15.0 check src tests→ cleanBehaviour change, disclosed: a
show_fileline longer than 500 characters is now rendered truncated with a notice instead of in full. That is the intent; no existing test exercises such a line.Note on overlap: this touches
steps/gate/__init__.py, as does my #4529, but a different function (_read_show_filevs_prompt). They should merge independently — happy to rebase whichever lands second.Written with assistance from Claude Code. Bug found, reproduced, and verified by me on current
main.🤖 Generated with Claude Code