-
Notifications
You must be signed in to change notification settings - Fork 51
Fix GitHub comment upload failure for large SQL linting reports #605
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
Fix GitHub comment upload failure for large SQL linting reports #605
Conversation
👷 Deploy request for squawkhq pending review.Visit the deploys page to approve it
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Left some minor comments!
- 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
…rings - Extract shared comment formatting logic into format_comment() function - Remove duplicate markdown template from get_comment_body() and get_summary_comment_body() - Improve code maintainability by centralizing template structure - Update test snapshots to reflect cleaner output (removed extra blank line) - Fix truncate_sql_if_needed() function signature to match actual usage
757daf2
to
81be829
Compare
Hi @sbdchd, thanks for the feedback, I have updated the PR, kindly review it again. Thanks 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
This PR currently has a merge conflict. Please resolve this and then re-add the |
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
GITHUB_COMMENT_MAX_SIZE
constant (65,000 chars) with safety margin2. Smart Comment Truncation
3. Summary Mode Fallback
4. Enhanced Error Handling
CommentTooLarge
error variant with descriptive messagesChanges Made
crates/squawk/src/github.rs
: Main comment generation logic with size checking and fallback modescrates/squawk_github/src/app.rs
: Enhanced error handling for comment size limitscrates/squawk_github/src/lib.rs
: New error variant for size-related failuresTesting
Successful Tests
Normal comment generation (6 violations)
Reference: #608 (comment)
SQL truncation (33 violations)
Reference: #608 (comment)
Multiple files handling
Reference: #608 (comment)
Error handling for oversized content
Large File Tests:
Analysis:
All existing tests continue to pass.
Fixes #603