Skip to content

Commit c4a6974

Browse files
authored
Merge pull request #1862 from microsoft/joshspicer/candidate-276146
[candidate] cloud agent: 422 useful error (#1857)
2 parents d6588ed + 5d43886 commit c4a6974

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
@@ -1239,7 +1239,22 @@ export class CopilotCloudSessionsProvider extends Disposable implements vscode.C
12391239
const response = await this._octoKitService.postCopilotAgentJob(repoId.org, repoId.repo, JOBS_API_VERSION, payload);
12401240
if (!this.validateRemoteAgentJobResponse(response)) {
12411241
const statusCode = response?.status;
1242-
return { error: vscode.l10n.t('Received invalid response {0}from cloud agent.', statusCode ? statusCode + ' ' : ''), innerError: `Response ${JSON.stringify(response)}`, state: 'error' };
1242+
switch (statusCode) {
1243+
case 422:
1244+
// NOTE: Although earlier checks should prevent this, ensure that if we end up
1245+
// with a 422 from the API, we give a useful error message
1246+
return {
1247+
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),
1248+
innerError: `Status code 422 received from cloud agent.`,
1249+
state: 'error',
1250+
};
1251+
default:
1252+
return {
1253+
error: vscode.l10n.t('Received invalid response {0}from cloud agent.', statusCode ? statusCode + ' ' : ''),
1254+
innerError: `Response ${JSON.stringify(response)}`,
1255+
state: 'error',
1256+
};
1257+
}
12431258
}
12441259
// For v1 API, we need to fetch the job details to get the PR info
12451260
// Since the PR might not be created immediately, we need to poll for it

0 commit comments

Comments
 (0)