mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-22 22:44:13 +08:00
feat: Improve error message for 403 permission errors when committing
When the github_file_ops MCP server gets a 403 error, it now shows a cleaner message suggesting to rebase from main/master branch to fix the issue.
This commit is contained in:
@@ -385,15 +385,22 @@ server.tool(
|
|||||||
|
|
||||||
if (!updateRefResponse.ok) {
|
if (!updateRefResponse.ok) {
|
||||||
const errorText = await updateRefResponse.text();
|
const errorText = await updateRefResponse.text();
|
||||||
|
|
||||||
|
// Provide a more helpful error message for 403 permission errors
|
||||||
|
if (updateRefResponse.status === 403) {
|
||||||
|
const permissionError = new Error(
|
||||||
|
`Permission denied: Unable to push commits to branch '${branch}'. ` +
|
||||||
|
`Please rebase your branch from the main/master branch to allow Claude to commit.\n\n` +
|
||||||
|
`Original error: ${errorText}`,
|
||||||
|
);
|
||||||
|
throw permissionError;
|
||||||
|
}
|
||||||
|
|
||||||
|
// For other errors, use the original message
|
||||||
const error = new Error(
|
const error = new Error(
|
||||||
`Failed to update reference: ${updateRefResponse.status} - ${errorText}`,
|
`Failed to update reference: ${updateRefResponse.status} - ${errorText}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Only retry on 403 errors - these are the intermittent failures we're targeting
|
|
||||||
if (updateRefResponse.status === 403) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
|
|
||||||
// For non-403 errors, fail immediately without retry
|
// For non-403 errors, fail immediately without retry
|
||||||
console.error("Non-retryable error:", updateRefResponse.status);
|
console.error("Non-retryable error:", updateRefResponse.status);
|
||||||
throw error;
|
throw error;
|
||||||
@@ -591,16 +598,23 @@ server.tool(
|
|||||||
|
|
||||||
if (!updateRefResponse.ok) {
|
if (!updateRefResponse.ok) {
|
||||||
const errorText = await updateRefResponse.text();
|
const errorText = await updateRefResponse.text();
|
||||||
|
|
||||||
|
// Provide a more helpful error message for 403 permission errors
|
||||||
|
if (updateRefResponse.status === 403) {
|
||||||
|
console.log("Received 403 error, will retry...");
|
||||||
|
const permissionError = new Error(
|
||||||
|
`Permission denied: Unable to push commits to branch '${branch}'. ` +
|
||||||
|
`Please rebase your branch from the main/master branch to allow Claude to commit.\n\n` +
|
||||||
|
`Original error: ${errorText}`,
|
||||||
|
);
|
||||||
|
throw permissionError;
|
||||||
|
}
|
||||||
|
|
||||||
|
// For other errors, use the original message
|
||||||
const error = new Error(
|
const error = new Error(
|
||||||
`Failed to update reference: ${updateRefResponse.status} - ${errorText}`,
|
`Failed to update reference: ${updateRefResponse.status} - ${errorText}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Only retry on 403 errors - these are the intermittent failures we're targeting
|
|
||||||
if (updateRefResponse.status === 403) {
|
|
||||||
console.log("Received 403 error, will retry...");
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
|
|
||||||
// For non-403 errors, fail immediately without retry
|
// For non-403 errors, fail immediately without retry
|
||||||
console.error("Non-retryable error:", updateRefResponse.status);
|
console.error("Non-retryable error:", updateRefResponse.status);
|
||||||
throw error;
|
throw error;
|
||||||
|
|||||||
Reference in New Issue
Block a user