Skip to content

Commit 5d43886

Browse files
committed
cloud agent: 422 useful error (#1857)
1 parent fa8658d commit 5d43886

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/extension/chatSessions/vscode-node/copilotCloudSessionsProvider.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,22 @@ export class CopilotCloudSessionsProvider extends Disposable implements vscode.C
12341234
const response = await this._octoKitService.postCopilotAgentJob(repoId.org, repoId.repo, JOBS_API_VERSION, payload);
12351235
if (!this.validateRemoteAgentJobResponse(response)) {
12361236
const statusCode = response?.status;
1237-
return { error: vscode.l10n.t('Received invalid response {0}from cloud agent.', statusCode ? statusCode + ' ' : ''), innerError: `Response ${JSON.stringify(response)}`, state: 'error' };
1237+
switch (statusCode) {
1238+
case 422:
1239+
// NOTE: Although earlier checks should prevent this, ensure that if we end up
1240+
// with a 422 from the API, we give a useful error message
1241+
return {
1242+
error: vscode.l10n.t('The cloud agent was unable to create a pull request with the specified base branch \'{0}\'. Please push branch to the remote and try again.', base_ref),
1243+
innerError: `Status code 422 received from cloud agent.`,
1244+
state: 'error',
1245+
};
1246+
default:
1247+
return {
1248+
error: vscode.l10n.t('Received invalid response {0}from cloud agent.', statusCode ? statusCode + ' ' : ''),
1249+
innerError: `Response ${JSON.stringify(response)}`,
1250+
state: 'error',
1251+
};
1252+
}
12381253
}
12391254
// For v1 API, we need to fetch the job details to get the PR info
12401255
// Since the PR might not be created immediately, we need to poll for it

0 commit comments

Comments
 (0)