Closed
Conversation
- Add size checking to prevent 422 errors when comment exceeds GitHub's 65,536 character limit - Implement smart comment truncation with SQL preview limited to 50 lines - Add fallback to summary mode for very large reports that omits SQL content but preserves all violation information - Include clear notices when content is truncated or summarized - Add comprehensive tests for comment size handling Fixes sbdchd#603
- Add normal comment generation test (001_demo_normal_comment.sql) - Add SQL truncation test (002_demo_sql_truncation.sql) - Add GitHub Actions workflow for testing - Add documentation explaining the demo This allows testing of the GitHub comment size limit fix in a real PR environment to capture screenshots for documentation.
👷 Deploy request for squawkhq pending review.Visit the deploys page to approve it
|
Contributor
Author
Squawk Report🚒 6 violations across 1 file(s)
|
Contributor
Author
Squawk Report🚒 33 violations across 1 file(s)
|
Contributor
Author
Squawk Report🚒 39 violations across 2 file(s)
|
Contributor
Author
GitHub Comment Testing SummarySuccessful Tests:
Large File Tests:
Analysis:
|
kodiakhq bot
pushed a commit
that referenced
this pull request
Sep 2, 2025
## Summary This PR fixes issue #603 where Squawk fails to upload large linting reports to GitHub with a 422 "Unprocessable Entity" error. ## Problem When performing linting on large SQL migrations (14,000+ lines across multiple files), Squawk generates GitHub comments that exceed the API's 65,536 character limit, causing upload failures. ## Solution ### 1. Size Limit Enforcement - Added `GITHUB_COMMENT_MAX_SIZE` constant (65,000 chars) with safety margin - Pre-check comment size before API calls to provide better error messages ### 2. Smart Comment Truncation - Limit SQL preview to 50 lines per file with truncation notice - Preserve all violation information while reducing content size ### 3. Summary Mode Fallback - For very large reports, switch to summary mode that omits SQL content - Display file statistics, line counts, and violation details - Clear notice about content omission ### 4. Enhanced Error Handling - New `CommentTooLarge` error variant with descriptive messages - Better user feedback when size limits are exceeded ## Changes Made - **`crates/squawk/src/github.rs`**: Main comment generation logic with size checking and fallback modes - **`crates/squawk_github/src/app.rs`**: Enhanced error handling for comment size limits - **`crates/squawk_github/src/lib.rs`**: New error variant for size-related failures ## Testing ### Successful Tests #### Normal comment generation (6 violations) <img width="790" height="1090" alt="image" src="https://github.com/user-attachments/assets/54246721-3902-4f2b-898c-ce915f89d97d" /> Reference: #608 (comment) #### SQL truncation (33 violations) <img width="863" height="651" alt="image" src="https://github.com/user-attachments/assets/fd191aaa-deb4-4967-b213-0ffade69c98c" /> Reference: #608 (comment) #### Multiple files handling <img width="853" height="1003" alt="image" src="https://github.com/user-attachments/assets/356271a8-4754-4ae7-b57c-f0adc208ed64" /> Reference: #608 (comment) #### Error handling for oversized content ``` Error: Upload to GitHub failed Caused by: Comment size error: Comment body is too large (1165116 characters). GitHub API limit is 65,536 characters. ``` Large File Tests: - File: 60,000+ lines - Violations: 30,003 issues - Comment size: 1,165,116 characters (18x over limit) - Error caught: 'Comment body is too large' Analysis: - The fix is working for normal use cases - Error handling prevents GitHub API failures - Summary mode logic may need adjustment for extreme cases All existing tests continue to pass. Fixes #603
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GitHub Comment Testing Summary
Successful Tests:
Large File Tests:
Analysis: