mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-09-30 12:43:16 +00:00
fix: Better git error handling (#509)
This commit is contained in:
parent
6ac4deacd6
commit
ec0c93ef94
2 changed files with 35 additions and 4 deletions
|
|
@ -275,6 +275,16 @@ export async function initializeSandbox(
|
|||
"error",
|
||||
"Failed to clone repository. Please check your repo URL and permissions.",
|
||||
);
|
||||
const errorFields = {
|
||||
...(cloneRepoRes instanceof Error
|
||||
? {
|
||||
name: cloneRepoRes.name,
|
||||
message: cloneRepoRes.message,
|
||||
stack: cloneRepoRes.stack,
|
||||
}
|
||||
: cloneRepoRes),
|
||||
};
|
||||
logger.error("Cloning repository failed", errorFields);
|
||||
throw new Error("Failed to clone repository.");
|
||||
}
|
||||
const newBranchName =
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import { TIMEOUT_SEC } from "@open-swe/shared/constants";
|
|||
import { getSandboxErrorFields } from "../sandbox-error-fields.js";
|
||||
import { getRepoAbsolutePath } from "@open-swe/shared/git";
|
||||
import { ExecuteResponse } from "@daytonaio/sdk/src/types/ExecuteResponse.js";
|
||||
import { withRetry } from "../retry.js";
|
||||
|
||||
const logger = createLogger(LogLevel.INFO, "GitHub-Git");
|
||||
|
||||
|
|
@ -102,12 +103,32 @@ export async function checkoutBranchAndCommit(
|
|||
await sandbox.git.commit(absoluteRepoDir, "Apply patch", userName, userEmail);
|
||||
|
||||
// Push the changes using the git API so it handles authentication for us.
|
||||
await sandbox.git.push(
|
||||
absoluteRepoDir,
|
||||
"git",
|
||||
options.githubInstallationToken,
|
||||
const pushRes = await withRetry(
|
||||
async () => {
|
||||
return await sandbox.git.push(
|
||||
absoluteRepoDir,
|
||||
"git",
|
||||
options.githubInstallationToken,
|
||||
);
|
||||
},
|
||||
{ retries: 3, delay: 0 },
|
||||
);
|
||||
|
||||
if (pushRes instanceof Error) {
|
||||
const errorFields = {
|
||||
...(pushRes instanceof Error
|
||||
? {
|
||||
name: pushRes.name,
|
||||
message: pushRes.message,
|
||||
stack: pushRes.stack,
|
||||
cause: pushRes.cause,
|
||||
}
|
||||
: pushRes),
|
||||
};
|
||||
logger.error("Failed to push changes", errorFields);
|
||||
throw new Error("Failed to push changes");
|
||||
}
|
||||
|
||||
logger.info("Successfully checked out & committed changes.", {
|
||||
commitAuthor: userName,
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue