-
Notifications
You must be signed in to change notification settings - Fork 1
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
getPatch: avoid failing on more than 300 files #210
Conversation
fb41722
to
780f2ec
Compare
github api allows maximum 300 files to be diffed. In order to fix this issue, when we encounter any error, try to fetch the repo manually, so to have repo content, and diff locally.
780f2ec
to
9f1a06c
Compare
openai debug - [puLL-Merge] - brave/pull-merge@210 DescriptionThis pull request adds a fallback mechanism for the Possible Issues
Security Hotspots
ChangesChanges
sequenceDiagram
participant User
participant API
participant Local
User->>API: Request Diff
API-->>Local: API Failure
Local->>Local: Clone Repository
Local->>Local: Fetch Branches
Local->>Local: Generate Diff
Local->>Local: Read Diff File
Local-->>User: Return Patch Body
graph TD
A[User] --> B[API Request]
B -->|API Success| C[Get Patch From API]
B -->|API Failure| D[Clone Repository]
D --> E[Fetch Branches]
E --> F[Generate Diff]
F --> G[Read Diff File]
G --> H[Return Patch Body]
C --> H
G -->|Cleanup Temporary Directory| I[End]
|
bedrock debug - [puLL-Merge] - brave/pull-merge@210 DescriptionThis PR enhances the Possible Issues
Security Hotspots
ChangesChangessrc/getPatch.js:
sequenceDiagram
participant getPatch
participant GitHub API
participant LocalFileSystem
participant Git
getPatch->>GitHub API: Request PR Diff
alt Successful API Request
GitHub API->>getPatch: Return PR Diff
else API Request Fails
GitHub API->>getPatch: Error
getPatch->>GitHub API: Request Repo Info
GitHub API->>getPatch: Return Repo Info
getPatch->>GitHub API: Request PR Info
GitHub API->>getPatch: Return PR Info
getPatch->>Git: Clone Repository
Git->>LocalFileSystem: Create Local Repo
getPatch->>Git: Fetch Branches
getPatch->>Git: Generate Diff
Git->>LocalFileSystem: Save Diff File
getPatch->>LocalFileSystem: Read Diff File
getPatch->>LocalFileSystem: Delete Local Repo
end
getPatch->>GitHub API: Check if Repo is Private
GitHub API->>getPatch: Return Privacy Status
graph TD
A[getPatch Function] --> B{Use GitHub Token?}
B -->|Yes| C[Fetch Patch via GitHub API]
B -->|No| D[Try Fetch Diff via GitHub API]
D --> E{Fetch Successful?}
E -->|Yes| F[Use Fetched Diff]
E -->|No| G[Fallback Mechanism]
G --> H[Clone Repository]
H --> I[Fetch Branches]
I --> J[Generate Diff]
J --> K[Read Diff File]
K --> L[Clean Up]
C --> M[Return Patch]
F --> M
L --> M
|
anthropic debug - [puLL-Merge] - brave/pull-merge@210 DescriptionThis PR modifies the Possible Issues
Security Hotspots
ChangesChangessrc/getPatch.js:
sequenceDiagram
participant Client
participant getPatch
participant GitHubAPI
participant FileSystem
participant Git
Client->>getPatch: Call with PR details
alt Use GitHub API
getPatch->>GitHubAPI: Request PR diff
alt API request successful
GitHubAPI-->>getPatch: Return PR diff
else API request fails
GitHubAPI-->>getPatch: Error
getPatch->>GitHubAPI: Request repo and PR info
GitHubAPI-->>getPatch: Return info
getPatch->>FileSystem: Create temp directory
getPatch->>Git: Clone repository
getPatch->>Git: Fetch branches
getPatch->>Git: Generate diff
getPatch->>FileSystem: Read diff file
getPatch->>FileSystem: Clean up temp directory
end
else Use custom URL
getPatch->>GitHubAPI: Fetch patch using custom URL
end
getPatch-->>Client: Return patch
graph TD
A[getPatch function] --> B{Use GitHub API?}
B -->|Yes| C[Fetch patch using GitHub API]
B -->|No| D[Fetch patch using custom URL]
C --> E{API request successful?}
E -->|Yes| F[Return patch]
E -->|No| G[Fallback to manual cloning]
G --> H[Clone repository]
H --> I[Fetch branches]
I --> J[Generate diff]
J --> K[Read diff file]
K --> L[Clean up cloned repo]
L --> F
D --> F
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PostMerged reviewed. This looks to address the issue with the PR which is that we're limited to 300 files. What happens when it throws an error from not enough tokens available? Seems like a potentially more robust way to handle this would be to generate intermediate outputs that get passed back in with new context such that there's an intermediate response returned until there's no more context left to pass in the final prompt. I'm not sure if that's a plausible solution in this scenario but it's a pattern I've seen used when dealing with extremely large amounts of context.
github api allows maximum 300 files to be diffed.
In order to fix this issue, when we encounter any error, try to fetch the repo manually, so to have repo content, and diff locally.