-
Notifications
You must be signed in to change notification settings - Fork 51
Test GitHub comment demo #608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
|
Squawk Report🚒 6 violations across 1 file(s)
|
Squawk Report🚒 33 violations across 1 file(s)
|
Squawk Report🚒 39 violations across 2 file(s)
|
GitHub Comment Testing SummarySuccessful Tests:
Large File Tests:
Analysis:
|
## 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
GitHub Comment Testing Summary
Successful Tests:
Large File Tests:
Analysis: