Skip to content

fix(read_file): honor configured fileReadLineLimit - #637

Open
aim9sour wants to merge 1 commit into
wonderwhy-er:mainfrom
aim9sour:fix/read-file-configured-default
Open

fix(read_file): honor configured fileReadLineLimit#637
aim9sour wants to merge 1 commit into
wonderwhy-er:mainfrom
aim9sour:fix/read-file-configured-default

Conversation

@aim9sour

@aim9sour aim9sour commented Aug 19, 2026

Copy link
Copy Markdown

Summary

  • let the existing read_file handler apply config.fileReadLineLimit when callers omit length
  • preserve explicit length values as the higher-priority per-call override
  • add a regression test covering both omitted and explicit length

Root cause

ReadFileArgsSchema assigned length a hardcoded Zod default of 1000. Because handleReadFile parses arguments before applying its configured fallback, an omitted length arrived at the handler as 1000, so parsed.length ?? config.fileReadLineLimit could never use the configured value.

The lower-level file reader already honors fileReadLineLimit when no length is supplied, so the fix is to leave the schema field optional instead of injecting a second default.

Testing

  • reproduced on current main with fileReadLineLimit: 7: omitted length read 1000 lines while the lower-level reader read 7
  • regression test fails before the fix and passes after it
  • npm test: 48 passed, 0 failed
  • git diff --check

Addresses the fileReadLineLimit report in #147.

Summary by CodeRabbit

  • Bug Fixes

    • File reading now uses the configured line limit when no length is specified.
    • Explicit line limits continue to override the configured default.
  • Tests

    • Added coverage verifying default and custom line-limit behavior when reading files.

@aim9sour aim9sour mentioned this pull request Aug 19, 2026
@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 440e0e86-eb53-4a1a-8461-9a42012ba7a9

📥 Commits

Reviewing files that changed from the base of the PR and between 9bd8422 and 6d90f34.

📒 Files selected for processing (2)
  • src/tools/schemas.ts
  • test/test-read-file-line-limit.js

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The read-file schema no longer assigns a default length. A new integration test verifies that omitted lengths use fileReadLineLimit, while explicit lengths override the configured limit.

Changes

Read file line limit

Layer / File(s) Summary
Read-file length fallback and validation
src/tools/schemas.ts, test/test-read-file-line-limit.js
ReadFileArgsSchema.length remains optional without a default. The integration test verifies configured and explicit read lengths and restores temporary configuration.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 6d90f

This localized change makes omitted file length use the configured line limit while preserving explicit per-call limits. No actionable merge-blocking risk remains after normal checks and review.

Possibly related PRs

Suggested reviewers: wonderwhy-er, edgarsskore

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: making read_file honor the configured fileReadLineLimit.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@aim9sour

Copy link
Copy Markdown
Author

Overlap note for maintainers: #551 predates this PR and already contains the same removal of the schema-level ReadFileArgsSchema.length default as one part of a much broader hardening change. This PR was independently reproduced against current v0.2.47 and intentionally stays focused, with a dedicated runtime regression test for configured fileReadLineLimit plus explicit-length precedence. If #551 lands first, this can be rebased or closed as appropriate.

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