Improve experience when controller repo does not exist

The controller repo is set via the `codeQL.variantAnalysis.controllerRepo`
setting in VSCode.

While we have validation to check that the repo is not null and the
format of the controller repo is correct: `<owner>/<repo>`, we still
allow you to provide a non-existent repo (e.g. a mispelled one).

When the MRVA request is sent over to the API, it will verify that the
repo exists and return a very generic "Not Found" response.

This will then be logged out in the "Output" tab for VSCode.

We'd like to give users a better indication of what has gone wrong in
this case so we're making the error message more verbose.

Co-authored-by: Charis Kyriakou <charisk@github.com>
Co-authored-by: Shati Patel <shati-patel@github.com>
This commit is contained in:
Elena Tanasoiu
2022-06-21 21:47:48 +01:00
parent b2906257a1
commit e5f3a973a0

View File

@@ -333,8 +333,12 @@ async function runRemoteQueriesApiRequest(
const { popupMessage, logMessage } = parseResponse(owner, repo, response.data);
void showAndLogInformationMessage(popupMessage, { fullMessage: logMessage });
return response.data.workflow_run_id;
} catch (error) {
void showAndLogErrorMessage(getErrorMessage(error));
} catch (error: any) {
if (error.status === 404) {
void showAndLogErrorMessage(`Controller repository was not found. Please make sure it's a valid repo name.${eol}`);
} else {
void showAndLogErrorMessage(getErrorMessage(error));
}
}
}