Skip to content

CreateIssueAsync does not validate or sanitize issue title length for GitHub API constraints #2007

Description

@Widthdom

Summary

At line 123 in GitHubIssueReporter.cs, the issue title is constructed as "[AI Suggestion] {record.Category}: {shortDesc}" where shortDesc is truncated to 60 chars (line 120-122). However, GitHub's REST API enforces a maximum title length (typically 255 chars per API docs), and the category name + prefix + scrubbed description could exceed this. No validation checks the final title length before POSTing, risking API 422 (Unprocessable Entity) errors that fail silently with generic error handling at line 179.

Where

  • src/CodeIndex/Cli/GitHubIssueReporter.cs:119-123
  • src/CodeIndex/Cli/GitHubIssueReporter.cs:176-180 (generic error handling)

Suggested approach

  1. Research GitHub API's exact title length limit and document it with a constant in GitHubIssueReporter
  2. Add validation after line 123 to assert that title.Length <= MaxTitleLength; truncate or return error if exceeded
  3. Test title construction with edge cases: max-length category names (if categories can be dynamically added), very long scrubbed descriptions
  4. Improve error handling at line 179 to detect 422 status and provide specific guidance: "Issue title may be too long or body is invalid"
  5. Add unit test for title validation edge cases
  6. Consider moving title construction logic into a separate, testable method with clear pre/post conditions

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions