mirror of
https://github.com/stablyai/orca.git
synced 2026-11-03 02:27:43 +00:00
fix(i18n): localize hosted review creation errors (#33368)
Main now tags each Orca-authored PR/MR create failure with a reason code (the English error is unchanged for mobile, older clients and logs), and the renderer maps the reason to translated copy in the Source Control notice, the Checks panel and the pre-create blocked notice. Sign-in steps are single-sourced across providers. Fixes #33321 Co-authored-by: Neil <4138956+nwparker@users.noreply.github.com>
This commit is contained in:
@@ -387,6 +387,7 @@ describe('createGitHubPullRequest', () => {
|
||||
ok: false,
|
||||
code: 'already_exists',
|
||||
error: 'A pull request already exists for this branch.',
|
||||
reason: 'existing_review',
|
||||
existingReview: {
|
||||
number: 44,
|
||||
url: 'https://github.com/acme/widgets/pull/44'
|
||||
@@ -432,7 +433,8 @@ describe('createGitHubPullRequest', () => {
|
||||
).resolves.toEqual({
|
||||
ok: false,
|
||||
code: 'validation',
|
||||
error: 'Create PR failed: choose a different base branch before creating a pull request.'
|
||||
error: 'Create PR failed: choose a different base branch before creating a pull request.',
|
||||
reason: 'same_base_branch'
|
||||
})
|
||||
|
||||
expect(ghExecFileAsyncMock).not.toHaveBeenCalled()
|
||||
|
||||
@@ -35,7 +35,8 @@ export async function createGitHubPullRequest(
|
||||
return {
|
||||
ok: false,
|
||||
code: 'unsupported_provider',
|
||||
error: 'Creating reviews for this provider is not supported yet.'
|
||||
error: 'Creating reviews for this provider is not supported yet.',
|
||||
reason: 'provider_not_supported'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +53,8 @@ export async function createGitHubPullRequest(
|
||||
return {
|
||||
ok: false,
|
||||
code: 'unsupported_provider',
|
||||
error: 'Creating pull requests requires a GitHub remote.'
|
||||
error: 'Creating pull requests requires a GitHub remote.',
|
||||
reason: 'unsupported_provider'
|
||||
}
|
||||
}
|
||||
// The runner qualifies --repo using options.host.
|
||||
@@ -72,7 +74,8 @@ export async function createGitHubPullRequest(
|
||||
return {
|
||||
ok: false,
|
||||
code: 'validation',
|
||||
error: 'Create PR failed: choose a different base branch before creating a pull request.'
|
||||
error: 'Create PR failed: choose a different base branch before creating a pull request.',
|
||||
reason: 'same_base_branch'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +136,8 @@ export async function createGitHubPullRequest(
|
||||
return {
|
||||
ok: false,
|
||||
code: 'unknown_completion',
|
||||
error: 'PR creation may have completed. Refreshing branch review state...'
|
||||
error: 'PR creation may have completed. Refreshing branch review state...',
|
||||
reason: 'creation_unconfirmed'
|
||||
}
|
||||
} catch (error) {
|
||||
const classified = classifyCreatePRError(error)
|
||||
@@ -155,6 +159,7 @@ export async function createGitHubPullRequest(
|
||||
ok: false,
|
||||
code: 'already_exists',
|
||||
error: 'A pull request already exists for this branch.',
|
||||
reason: 'existing_review',
|
||||
existingReview: existing
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,21 +18,24 @@ export function classifyCreatePRError(error: unknown): CreateHostedReviewResult
|
||||
ok: false,
|
||||
code: 'auth_required',
|
||||
error:
|
||||
'Create PR failed: GitHub is not authenticated. Next step: run gh auth login in this environment.'
|
||||
'Create PR failed: GitHub is not authenticated. Next step: run gh auth login in this environment.',
|
||||
reason: 'auth_required'
|
||||
}
|
||||
}
|
||||
if (lower.includes('already exists') || lower.includes('a pull request already exists')) {
|
||||
return {
|
||||
ok: false,
|
||||
code: 'already_exists',
|
||||
error: 'A pull request already exists for this branch.'
|
||||
error: 'A pull request already exists for this branch.',
|
||||
reason: 'existing_review'
|
||||
}
|
||||
}
|
||||
if (lower.includes('timed out') || lower.includes('timeout')) {
|
||||
return {
|
||||
ok: false,
|
||||
code: 'unknown_completion',
|
||||
error: 'PR creation may have completed. Refreshing branch review state...'
|
||||
error: 'PR creation may have completed. Refreshing branch review state...',
|
||||
reason: 'creation_unconfirmed'
|
||||
}
|
||||
}
|
||||
if (lower.includes('validation failed') || lower.includes('http 422')) {
|
||||
@@ -40,13 +43,15 @@ export function classifyCreatePRError(error: unknown): CreateHostedReviewResult
|
||||
ok: false,
|
||||
code: 'validation',
|
||||
error:
|
||||
'Create PR failed: GitHub rejected the pull request. Check the base branch and branch state, then try again.'
|
||||
'Create PR failed: GitHub rejected the pull request. Check the base branch and branch state, then try again.',
|
||||
reason: 'rejected'
|
||||
}
|
||||
}
|
||||
return {
|
||||
ok: false,
|
||||
code: 'unknown',
|
||||
error: 'Create PR failed: GitHub could not create the pull request. Try again in a moment.'
|
||||
error: 'Create PR failed: GitHub could not create the pull request. Try again in a moment.',
|
||||
reason: 'create_failed'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user