mirror of
https://github.com/codeflash-ai/codeflash-internal.git
synced 2026-05-04 18:25:18 +00:00
Enhance error handling for GitHub App installation checks in code context hash endpoints. Added specific exceptions for installation not found and installation errors, improving logging and user guidance for installation issues.
This commit is contained in:
parent
d5180b643a
commit
8d19be486e
1 changed files with 28 additions and 2 deletions
|
|
@ -12,6 +12,8 @@ import {
|
|||
validationFailure,
|
||||
internalServerError,
|
||||
conflict,
|
||||
githubInstallationNotFound,
|
||||
githubInstallationError,
|
||||
} from "../exceptions/index.js"
|
||||
|
||||
export async function is_code_being_optimized_again(req: Request, res: Response) {
|
||||
|
|
@ -28,7 +30,19 @@ export async function is_code_being_optimized_again(req: Request, res: Response)
|
|||
}
|
||||
const octokit = await getInstallationOctokitByOwner(githubApp, owner, repo, userId)
|
||||
if (octokit instanceof Error) {
|
||||
throw internalServerError(octokit.message)
|
||||
const errorMessage = octokit.message
|
||||
if (errorMessage.includes("not installed")) {
|
||||
const installationLink = "https://github.com/apps/codeflash-ai/installations/select_target"
|
||||
logger.warn("GitHub App not installed on repository", req, {
|
||||
repo: `${owner}/${repo}`,
|
||||
installationLink,
|
||||
})
|
||||
throw githubInstallationNotFound(
|
||||
`${owner}/${repo}. Please install the GitHub App at: ${installationLink}`,
|
||||
)
|
||||
} else {
|
||||
throw githubInstallationError(errorMessage)
|
||||
}
|
||||
}
|
||||
|
||||
// Check collaborator status with error handling
|
||||
|
|
@ -164,7 +178,19 @@ export async function add_optimized_code_context(req: Request, res: Response) {
|
|||
|
||||
const octokit = await getInstallationOctokitByOwner(githubApp, owner, repo, userId)
|
||||
if (octokit instanceof Error) {
|
||||
throw internalServerError(octokit.message)
|
||||
const errorMessage = octokit.message
|
||||
if (errorMessage.includes("not installed")) {
|
||||
const installationLink = "https://github.com/apps/codeflash-ai/installations/select_target"
|
||||
logger.warn("GitHub App not installed on repository", req, {
|
||||
repo: `${owner}/${repo}`,
|
||||
installationLink,
|
||||
})
|
||||
throw githubInstallationNotFound(
|
||||
`${owner}/${repo}. Please install the GitHub App at: ${installationLink}`,
|
||||
)
|
||||
} else {
|
||||
throw githubInstallationError(errorMessage)
|
||||
}
|
||||
}
|
||||
|
||||
// Check collaborator status with error handling
|
||||
|
|
|
|||
Loading…
Reference in a new issue