From 469efbb83aa4ece2060f0905f68a2130f8eda419 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 5 Jun 2026 12:51:30 +0100 Subject: [PATCH] fix(github): drop per-file patch in getPullRequestFiles to bound memory getPullRequestFiles() paginated a pull request's files and accumulated the full GitHub file objects -- including each file's `patch` (the complete unified diff) -- into one array before returning. `patch` is the only unbounded field (KBs-MBs per file) and grows with PR size, so a large PR (thousands of files, e.g. generated code / lockfiles / vendored deps) materialised every diff in memory at once -- hundreds of MB in a single request. No caller uses `patch`; both consumers only read `filename` / `previous_filename`. Strip `patch` per page while paginating. The return shape is preserved (array of file objects keyed by `filename`, etc.), so memory is bounded to lightweight per-file metadata. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/VCS/Adapter/Git/GitHub.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/VCS/Adapter/Git/GitHub.php b/src/VCS/Adapter/Git/GitHub.php index 1af30388..e23584a8 100644 --- a/src/VCS/Adapter/Git/GitHub.php +++ b/src/VCS/Adapter/Git/GitHub.php @@ -713,7 +713,10 @@ public function getPullRequestFiles(string $owner, string $repositoryName, int $ ]); $files = $response['body'] ?? []; - $allFiles = array_merge($allFiles, $files); + foreach ($files as $file) { + unset($file['patch']); + $allFiles[] = $file; + } if (\count($files) < $perPage) { break;