Skip to content

feat: filter files exceeding API size limits before sending review#4

Merged
malinosqui merged 2 commits intomainfrom
feat/filter-api-limits
Feb 5, 2026
Merged

feat: filter files exceeding API size limits before sending review#4
malinosqui merged 2 commits intomainfrom
feat/filter-api-limits

Conversation

@malinosqui
Copy link
Member

@malinosqui malinosqui commented Feb 5, 2026

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:

  • Maximum Diff Size: Files with a diff exceeding 500KB will be skipped.
  • Maximum File Content Size: Files with full content exceeding 2MB will be skipped.
  • Maximum Number of Files: If more than 100 files remain after individual size filtering, only the first 100 files will be sent for review.

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.

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>
@kody-ai

This comment has been minimized.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

private filterFiles(files: FileContent[]): FileContent[] {
const skipped: string[] = [];
const filtered = files.filter(f => {
if (f.diff.length > MAX_DIFF_SIZE) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@kody-ai
Copy link

kody-ai bot commented Feb 5, 2026

kody code-review Kody Rules critical

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-ai
Copy link

kody-ai bot commented Feb 5, 2026

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug
Performance
Security
Cross File

Access your configuration settings here.

@kody-ai
Copy link

kody-ai bot commented Feb 5, 2026

kody code-review Kody Rules critical

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

@malinosqui malinosqui merged commit a1bf740 into main Feb 5, 2026
2 checks passed
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