@@ -775,6 +775,8 @@ func handleIssueCommentEvent(gh utils.GithubClientProvider, payload *github.Issu
775775
776776 // Get all code content from the repository at a specific commit
777777 getCodeFromCommit := func (ghService * dg_github.GithubService , repoOwner , repoName string , commitSha * string , projectDir string ) (string , error ) {
778+ const MaxPatchSize = 1024 * 1024 // 1MB limit
779+
778780 // Get the commit's changes compared to default branch
779781 comparison , _ , err := ghService .Client .Repositories .CompareCommits (
780782 context .Background (),
@@ -790,10 +792,13 @@ func handleIssueCommentEvent(gh utils.GithubClientProvider, payload *github.Issu
790792
791793 var appCode strings.Builder
792794 for _ , file := range comparison .Files {
795+ if file .Size > MaxPatchSize {
796+ return "" , fmt .Errorf ("file %s exceeds maximum allowed size" , * file .Filename )
797+ }
793798 if file .Patch == nil {
794799 continue // Skip files without patches
795800 }
796- log .Printf ("file patch: %v " , * file .Patch )
801+ log .Printf ("Processing patch for file : %s " , * file .Filename )
797802 if * file .Additions > 0 {
798803 lines := strings .Split (* file .Patch , "\n " )
799804 for _ , line := range lines {
@@ -807,7 +812,7 @@ func handleIssueCommentEvent(gh utils.GithubClientProvider, payload *github.Issu
807812 }
808813
809814 if appCode .Len () == 0 {
810- return "" , fmt .Errorf ("no changes found in commit: %s" , * commitSha )
815+ return "" , fmt .Errorf ("no code changes found in commit %s. Please ensure the PR contains added or modified code " , * commitSha )
811816 }
812817
813818 return appCode .String (), nil
0 commit comments