8000 fix: handle GitHub issue body character limit in code quality workflow by wtfsayo · Pull Request #5541 · elizaOS/eliza · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: handle GitHub issue body character limit in code quality workflow #5541

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

Merged
merged 2 commits into from
Jul 11, 2025

Conversation

wtfsayo
Copy link
Member
@wtfsayo wtfsayo commented Jul 11, 2025

Description

This PR fixes a critical issue that was discovered after the previous PR was merged. The daily code quality analysis workflow was failing because the generated issue body exceeded GitHub's 65,536 character limit.

Problem

The workflow failed with error:

Failed to create issue: Validation Failed: {"resource":"Issue","code":"custom","field":"body","message":"body is too long (maximum is 65536 characters)"}

This happened because the full analysis report can be very large, especially for large codebases.

Solution

Added truncation logic to the issue creation step:

  1. Smart Truncation: If report exceeds 50,000 characters, truncate it
  2. Line Boundary Cutting: Truncate at the nearest line boundary to maintain valid markdown
  3. User Notification: Add a note when truncated, directing users to workflow artifacts
  4. Safety Margin: Truncate at 50k to leave room for the rest of issue body

Changes

  • Added character limit check before creating issue
  • Implemented smart truncation at line boundaries
  • Added informative message when report is truncated
  • Full report remains available in workflow artifacts (30-day retention)

Testing

  • Workflow will now handle large analysis reports gracefully
  • Truncated reports will display a note directing to full artifacts
  • No data is lost - full report always available as downloadable artifact

Fixes the workflow failure seen in: https://github.com/elizaOS/eliza/actions/runs/16222104255/job/45804965964

- Add truncation logic to prevent exceeding GitHub's 65536 character limit
- Truncate report at 50k characters to leave room for rest of issue body
- Cut at line boundary to maintain valid markdown
- Add note when report is truncated directing to workflow artifacts
Copy link
Contributor
coderabbitai bot commented Jul 11, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/issue-body-character-limit

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor
claude bot commented Jul 11, 2025

Claude finished @wtfsayo's task —— View job


PR Review: GitHub Issue Body Character Limit Fix

Todo List:

  • Read and analyze the workflow file changes
  • Check for security vulnerabilities
  • Verify truncation logic implementation
  • Assess test coverage requirements
  • Review against CLAUDE.md guidelines
  • Provide comprehensive review feedback

Review Summary

OVERALL ASSESSMENT:APPROVED - This is a well-implemented fix that addresses the critical workflow failure.

Code Quality Review

SECURITY ANALYSIS: PASSED

  • No security vulnerabilities detected
  • No exposed secrets or credentials
  • No unsafe operations introduced
  • Proper handling of user input (file content)

IMPLEMENTATION ANALYSIS: EXCELLENT

Truncation Logic (lines 504-512):

// GitHub has a 65536 character limit for issue bodies
const maxReportLength = 50000; // Leave room for the rest of the issue body
let reportTruncated = false;
if (reportContent.length > maxReportLength) {
  // Truncate at a line boundary to keep markdown valid
  const truncateAt = reportContent.lastIndexOf('\n', maxReportLength);
  reportContent = reportContent.substring(0, truncateAt > 0 ? truncateAt : maxReportLength);
  reportTruncated = true;
}

Strengths:

  • Smart truncation: Uses lastIndexOf('\n') to cut at line boundaries, preserving markdown integrity
  • Safety margin: 50k limit leaves 15k+ characters for issue metadata
  • Fallback handling: Falls back to character-based truncation if no line break found
  • User notification: Clear message directing users to w 8000 orkflow artifacts

User Experience Enhancement (lines 559-560):

${reportTruncated ? '\n\n**Note:** The full report was truncated due to GitHub\'s character limit. View the complete report in the workflow artifacts.' : ''}
  • Clear communication: Users know when content is truncated
  • Alternative access: Directs to workflow artifacts for full report
  • No data loss: Full report always available (30-day retention)

TESTING REQUIREMENTS: ACCEPTABLE

Why testing is not required for this change:

  • This is a GitHub Actions workflow configuration change, not application code
  • The logic is straightforward string manipulation with well-defined behavior
  • Testing would require complex workflow mocking that provides little value
  • The fix addresses an operational issue that can be verified through workflow execution

ELIZAOS STANDARDS COMPLIANCE: PASSED

  • Uses JavaScript (appropriate for GitHub Actions)
  • No TypeScript violations (not applicable)
  • No dependency or import issues
  • Follows functional programming approach
  • No security vulnerabilities introduced

DOCUMENTATION: ADEQUATE

  • Clear inline comments explaining the GitHub character limit
  • Informative user message about truncation
  • PR description provides comprehensive context

Critical Issues Found

None - This is a clean, well-implemented fix.

Suggestions for Improvement

💡 MINOR SUGGESTION: Enhanced Error Handling

Consider adding validation for edge cases:

if (reportContent.length > maxReportLength) {
  const truncateAt = reportContent.lastIndexOf('\n', maxReportLength);
  // Ensure we don't truncate to zero length
  const finalTruncateAt = truncateAt > 1000 ? truncateAt : maxReportLength;
  reportContent = reportContent.substring(0, finalTruncateAt);
  reportTruncated = true;
}

💡 MINOR SUGGESTION: Truncation Statistics

Could add truncation details to the user message:

**Note:** The full report was truncated from ${originalLength} to ${reportContent.length} characters due to GitHub's character limit. View the complete report in the workflow artifacts.

Final Assessment

This PR successfully addresses the critical workflow failure with a pragmatic, well-implemented solution. The truncation logic is smart, safe, and user-friendly. The fix ensures the daily code quality analysis can continue functioning while preserving all data through workflow artifacts.

Recommendation:MERGE - This fix should be merged to restore workflow functionality.


@wtfsayo wtfsayo merged commit d2b0184 into develop Jul 11, 2025
4 of 7 checks passed
@wtfsayo wtfsayo deleted the fix/issue-body-character-limit branch July 11, 2025 14:20
Copy link
@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Bug: Report Truncation and Summary Mismatch

The code quality analysis workflow has two issues:

  1. Incorrect Report Truncation: The logic to truncate the reportContent uses truncateAt > 0 instead of truncateAt >= 0. This incorrectly treats a newline at position 0 as if no line boundary was found, causing the report to be truncated at maxReportLength instead of at the intended line boundary, potentially leading to improperly formatted or still-too-long content.
  2. Inaccurate Summary Statistics: The summaryStats (e.g., deadCode, security) are calculated after the reportContent is truncated. This means that if the report exceeds the maxReportLength, the displayed summary counts will be based on the truncated content, leading to inaccurate (lower) statistics compared to the full analysis results.

.github/workflows/daily-code-quality-analysis.yml#L503-L523

// GitHub has a 65536 character limit for issue bodies
const maxReportLength = 50000; // Leave room for the rest of the issue body
let reportTruncated = false;
if (reportContent.length > maxReportLength) {
// Truncate at a line boundary to keep markdown valid
const truncateAt = reportContent.lastIndexOf('\n', maxReportLength);
reportContent = reportContent.substring(0, truncateAt > 0 ? truncateAt : maxReportLength);
reportTruncated = true;
}
// Count issues for summary
let summaryStats = {
deadCode: 0,
security: 0,
typeSafety: 0,
testCoverage: 0,
codeQuality: 0,
documentation: 0,
repoStandards: 0
};

Fix in CursorFix in Web


Was this report helpful? Give feedback by reacting with 👍 or 👎

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
0