diff --git a/extension/tasks/dependabotV2/index.ts b/extension/tasks/dependabotV2/index.ts index d9811c2c..b1ee6025 100644 --- a/extension/tasks/dependabotV2/index.ts +++ b/extension/tasks/dependabotV2/index.ts @@ -111,25 +111,27 @@ async function run() { failedJobs++; } - // Run an update job for each existing pull request; this will resolve merge conflicts and close pull requests that are no longer needed - if (!taskInputs.skipPullRequests) { - for (const pullRequestId in existingPullRequests) { - const updatePullRequestJob = DependabotJobBuilder.newUpdatePullRequestJob( - taskInputs, - pullRequestId, - update, - dependabotConfig.registries, - existingPullRequestDependencies, - existingPullRequests[pullRequestId], - ); - const updatePullRequestOutputs = await dependabot.update(updatePullRequestJob, dependabotUpdaterOptions); - if (!updatePullRequestOutputs || updatePullRequestOutputs.filter((u) => !u.success).length > 0) { - updatePullRequestOutputs.filter((u) => !u.success).forEach((u) => exception(u.error)); - failedJobs++; + // If there are existing pull requests, run an update job for each one; this will resolve merge conflicts and close pull requests that are no longer needed + if (existingPullRequests && existingPullRequests.keys.length > 0) { + if (!taskInputs.skipPullRequests) { + for (const pullRequestId in existingPullRequests) { + const updatePullRequestJob = DependabotJobBuilder.newUpdatePullRequestJob( + taskInputs, + pullRequestId, + update, + dependabotConfig.registries, + existingPullRequestDependencies, + existingPullRequests[pullRequestId], + ); + const updatePullRequestOutputs = await dependabot.update(updatePullRequestJob, dependabotUpdaterOptions); + if (!updatePullRequestOutputs || updatePullRequestOutputs.filter((u) => !u.success).length > 0) { + updatePullRequestOutputs.filter((u) => !u.success).forEach((u) => exception(u.error)); + failedJobs++; + } } + } else { + warning(`Skipping update of existing pull requests as 'skipPullRequests' is set to 'true'`); } - } else if (existingPullRequests.keys.length > 0) { - warning(`Skipping update of existing pull requests as 'skipPullRequests' is set to 'true'`); } } @@ -150,7 +152,7 @@ async function run() { function exception(e: Error) { if (e) { error(`An unhandled exception occurred: ${e}`); - console.error(e); + console.debug(e); // Dump the stack trace to help with debugging } } diff --git a/extension/tasks/dependabotV2/utils/azure-devops/AzureDevOpsWebApiClient.ts b/extension/tasks/dependabotV2/utils/azure-devops/AzureDevOpsWebApiClient.ts index 7091661e..95e9e5d9 100644 --- a/extension/tasks/dependabotV2/utils/azure-devops/AzureDevOpsWebApiClient.ts +++ b/extension/tasks/dependabotV2/utils/azure-devops/AzureDevOpsWebApiClient.ts @@ -68,7 +68,7 @@ export class AzureDevOpsWebApiClient { return repo.defaultBranch; } catch (e) { error(`Failed to get default branch for '${project}/${repository}': ${e}`); - console.error(e); + console.debug(e); // Dump the error stack trace to help with debugging return undefined; } } @@ -114,7 +114,7 @@ export class AzureDevOpsWebApiClient { ); } catch (e) { error(`Failed to list active pull request properties: ${e}`); - console.error(e); + console.debug(e); // Dump the error stack trace to help with debugging return []; } } @@ -264,7 +264,7 @@ export class AzureDevOpsWebApiClient { return pullRequest.pullRequestId; } catch (e) { error(`Failed to create pull request: ${e}`); - console.error(e); + console.debug(e); // Dump the error stack trace to help with debugging return null; } } @@ -348,7 +348,7 @@ export class AzureDevOpsWebApiClient { return true; } catch (e) { error(`Failed to update pull request: ${e}`); - console.error(e); + console.debug(e); // Dump the error stack trace to help with debugging return false; } } @@ -384,7 +384,7 @@ export class AzureDevOpsWebApiClient { console.info(` - Pull request #${options.pullRequestId} was approved.`); } catch (e) { error(`Failed to approve pull request: ${e}`); - console.error(e); + console.debug(e); // Dump the error stack trace to help with debugging return false; } } @@ -462,7 +462,7 @@ export class AzureDevOpsWebApiClient { return true; } catch (e) { error(`Failed to close pull request: ${e}`); - console.error(e); + console.debug(e); // Dump the error stack trace to help with debugging return false; } } @@ -482,7 +482,7 @@ export class AzureDevOpsWebApiClient { return properties.map((p) => ({ [p.name]: p.value })).reduce((a, b) => ({ ...a, ...b }), {}); } catch (e) { error(`Failed to get project properties: ${e}`); - console.error(e); + console.debug(e); // Dump the error stack trace to help with debugging return undefined; } } @@ -517,7 +517,7 @@ export class AzureDevOpsWebApiClient { ]); } catch (e) { error(`Failed to update project property '${name}': ${e}`); - console.error(e); + console.debug(e); // Dump the error stack trace to help with debugging } } } diff --git a/extension/tasks/dependabotV2/utils/dependabot-cli/DependabotOutputProcessor.ts b/extension/tasks/dependabotV2/utils/dependabot-cli/DependabotOutputProcessor.ts index d5571519..5ffb958d 100644 --- a/extension/tasks/dependabotV2/utils/dependabot-cli/DependabotOutputProcessor.ts +++ b/extension/tasks/dependabotV2/utils/dependabot-cli/DependabotOutputProcessor.ts @@ -224,13 +224,11 @@ export class DependabotOutputProcessor implements IDependabotUpdateOutputProcess break; case 'record_update_job_error': - error(`Update job error: ${data['error-type']}`); - console.log(data['error-details']); + error(`Update job error: ${data['error-type']} ${JSON.stringify(data['error-details'])}`); return false; case 'record_update_job_unknown_error': - error(`Update job unknown error: ${data['error-type']}`); - console.log(data['error-details']); + error(`Update job unknown error: ${data['error-type']}, ${JSON.stringify(data['error-details'])}`); return false; case 'increment_metric':