@@ -775,6 +775,8 @@ func handleIssueCommentEvent(gh utils.GithubClientProvider, payload *github.Issu
775
775
776
776
// Get all code content from the repository at a specific commit
777
777
getCodeFromCommit := func (ghService * dg_github.GithubService , repoOwner , repoName string , commitSha * string , projectDir string ) (string , error ) {
778
+ const MaxPatchSize = 1024 * 1024 // 1MB limit
779
+
778
780
// Get the commit's changes compared to default branch
779
781
comparison , _ , err := ghService .Client .Repositories .CompareCommits (
780
782
context .Background (),
@@ -790,10 +792,13 @@ func handleIssueCommentEvent(gh utils.GithubClientProvider, payload *github.Issu
790
792
791
793
var appCode strings.Builder
792
794
for _ , file := range comparison .Files {
795
+ if file .Size > MaxPatchSize {
796
+ return "" , fmt .Errorf ("file %s exceeds maximum allowed size" , * file .Filename )
797
+ }
793
798
if file .Patch == nil {
794
799
continue // Skip files without patches
795
800
}
796
- log .Printf ("file patch: %v " , * file .Patch )
801
+ log .Printf ("Processing patch for file : %s " , * file .Filename )
797
802
if * file .Additions > 0 {
798
803
lines := strings .Split (* file .Patch , "\n " )
799
804
for _ , line := range lines {
@@ -807,7 +812,7 @@ func handleIssueCommentEvent(gh utils.GithubClientProvider, payload *github.Issu
807
812
}
808
813
809
814
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 )
811
816
}
812
817
813
818
return appCode .String (), nil
0 commit comments