feat: filter files exceeding API size limits before sending review#4
feat: filter files exceeding API size limits before sending review#4malinosqui merged 2 commits intomainfrom
Conversation
Add client-side validation to skip files with diff > 500KB, content > 2MB, and cap at 100 files per request to prevent API 400 errors. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c803b49491
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
src/services/review.service.ts
Outdated
| private filterFiles(files: FileContent[]): FileContent[] { | ||
| const skipped: string[] = []; | ||
| const filtered = files.filter(f => { | ||
| if (f.diff.length > MAX_DIFF_SIZE) { |
There was a problem hiding this comment.
Measure file sizes in bytes before applying size caps
The new size guard compares f.diff.length/f.content.length, but JavaScript string length is UTF-16 code units rather than payload bytes; with non-ASCII content (e.g., emojis or CJK text), files can pass this check while still exceeding the 500KB/2MB API byte limits and continue to trigger the same 400 errors this change is trying to prevent. Use Buffer.byteLength(..., 'utf8') for both diff/content checks (and reported sizes) so filtering matches the API constraints.
Useful? React with 👍 / 👎.
|
The pull request description does not contain a reference to a GitHub issue (e.g., 'Closes #123', 'Fixes #456', or simply '#789'). Please update the description to include a link to the relevant issue to improve tracking and context. Kody Rule violation: Ensure PR closes referenced issues |
string.length counts UTF-16 code units, not bytes. Non-ASCII content could pass the check while exceeding API byte limits. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Kody Review CompleteGreat news! 🎉 Keep up the excellent work! 🚀 Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
|
The pull request description does not contain a reference to a GitHub issue. To improve tracking and context, please add a closing keyword like 'Closes #123' or 'Fixes #123' to automatically link and close the relevant issue upon merging. Kody Rule violation: Ensure PR closes referenced issues |
Add client-side validation to skip files with diff > 500KB, content > 2MB, and cap at 100 files per request to prevent API 400 errors.
This pull request implements client-side filtering for files before they are sent for code review, ensuring that only files within defined API limits are processed.
The following limits are now enforced:
When files are skipped due to size limits or if the total file count is truncated, a warning message is displayed in the console, providing feedback on which files were affected and why. This helps prevent sending excessively large payloads to the review API and improves overall reliability.