Skip to content

Commit 7c10a0d

Browse files
committed
0.1.10:
Enhanced error handling for GitHub submission: Added try-catch around the submitSnapshot call with detailed error logging including HTTP status codes and response data. Added early validation: Check if manifests exist before attempting submission to avoid unnecessary API calls. Enhanced environment variable setup: Set additional environment variables that the dependency-submission-toolkit might expect: GITHUB_REPOSITORY GITHUB_API_URL GITHUB_SERVER_URL GITHUB_GRAPHQL_URL Improved debug logging: Added more detailed logging around the submission process including snapshot details and correlator information. Better manifest validation: Added check to ensure manifests aren't empty before proceeding with submission.
1 parent 7f6325b commit 7c10a0d

File tree

6 files changed

+92
-10
lines changed

6 files changed

+92
-10
lines changed

ado-dist/index.js

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35994,6 +35994,12 @@ function run() {
3599435994
platform.logger.debug(`GitHub Token provided: ${githubToken ? 'Yes' : 'No'}`);
3599535995
// Set the GitHub token in environment for dependency-submission-toolkit
3599635996
process.env.GITHUB_TOKEN = githubToken;
35997+
// Also set other environment variables that the toolkit might expect
35998+
process.env.GITHUB_REPOSITORY = githubRepository;
35999+
process.env.GITHUB_API_URL = 'https://api.github.com';
36000+
// The dependency-submission-toolkit might expect these GitHub Actions environment variables
36001+
process.env.GITHUB_SERVER_URL = 'https://github.com';
36002+
process.env.GITHUB_GRAPHQL_URL = 'https://api.github.com/graphql';
3599736003
let manifests = yield componentDetection_1.default.scanAndGetManifests(platform.input.getInput("filePath") || ".", platform);
3599836004
const correlatorInput = ((_a = platform.input.getInput("correlator")) === null || _a === void 0 ? void 0 : _a.trim()) || platform.context.getJobId();
3599936005
// Get detector configuration inputs
@@ -36059,9 +36065,30 @@ function run() {
3605936065
if (snapshotRef) {
3606036066
snapshot.ref = snapshotRef;
3606136067
}
36068+
if (!manifests || manifests.length === 0) {
36069+
platform.logger.warning("No manifests found. Skipping dependency submission.");
36070+
return;
36071+
}
36072+
platform.logger.info(`Submitting snapshot with ${snapshot.manifests.size} manifests to GitHub repository: ${repo.owner}/${repo.repo}`);
36073+
platform.logger.debug(`Snapshot SHA: ${snapshot.sha}`);
36074+
platform.logger.debug(`Snapshot Ref: ${snapshot.ref}`);
36075+
platform.logger.debug(`Correlator: ${correlatorInput}`);
3606236076
// Submit snapshot to GitHub (using the provided GitHub token)
36063-
yield (0, dependency_submission_toolkit_1.submitSnapshot)(snapshot);
36064-
platform.logger.info("Component detection and dependency submission completed successfully");
36077+
try {
36078+
yield (0, dependency_submission_toolkit_1.submitSnapshot)(snapshot);
36079+
platform.logger.info("Component detection and dependency submission completed successfully");
36080+
}
36081+
catch (submissionError) {
36082+
platform.logger.error(`Failed to submit snapshot to GitHub: ${submissionError.message}`);
36083+
if (submissionError.response) {
36084+
platform.logger.error(`HTTP Status: ${submissionError.response.status}`);
36085+
platform.logger.error(`Response: ${JSON.stringify(submissionError.response.data)}`);
36086+
}
36087+
if (submissionError.stack) {
36088+
platform.logger.debug(`Stack trace: ${submissionError.stack}`);
36089+
}
36090+
throw submissionError;
36091+
}
3606536092
}
3606636093
catch (error) {
3606736094
platform.logger.setFailed(`Component detection failed: ${error.message}`);

ado-dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ado-index.ts

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ async function run() {
3232

3333
// Set the GitHub token in environment for dependency-submission-toolkit
3434
process.env.GITHUB_TOKEN = githubToken;
35+
// Also set other environment variables that the toolkit might expect
36+
process.env.GITHUB_REPOSITORY = githubRepository;
37+
process.env.GITHUB_API_URL = 'https://api.github.com';
38+
39+
// The dependency-submission-toolkit might expect these GitHub Actions environment variables
40+
process.env.GITHUB_SERVER_URL = 'https://github.com';
41+
process.env.GITHUB_GRAPHQL_URL = 'https://api.github.com/graphql';
3542

3643
let manifests = await ComponentDetection.scanAndGetManifests(
3744
platform.input.getInput("filePath") || ".",
@@ -118,10 +125,31 @@ async function run() {
118125
snapshot.ref = snapshotRef;
119126
}
120127

121-
// Submit snapshot to GitHub (using the provided GitHub token)
122-
await submitSnapshot(snapshot);
128+
if (!manifests || manifests.length === 0) {
129+
platform.logger.warning("No manifests found. Skipping dependency submission.");
130+
return;
131+
}
123132

124-
platform.logger.info("Component detection and dependency submission completed successfully");
133+
platform.logger.info(`Submitting snapshot with ${snapshot.manifests.size} manifests to GitHub repository: ${repo.owner}/${repo.repo}`);
134+
platform.logger.debug(`Snapshot SHA: ${snapshot.sha}`);
135+
platform.logger.debug(`Snapshot Ref: ${snapshot.ref}`);
136+
platform.logger.debug(`Correlator: ${correlatorInput}`);
137+
138+
// Submit snapshot to GitHub (using the provided GitHub token)
139+
try {
140+
await submitSnapshot(snapshot);
141+
platform.logger.info("Component detection and dependency submission completed successfully");
142+
} catch (submissionError: any) {
143+
platform.logger.error(`Failed to submit snapshot to GitHub: ${submissionError.message}`);
144+
if (submissionError.response) {
145+
platform.logger.error(`HTTP Status: ${submissionError.response.status}`);
146+
platform.logger.error(`Response: ${JSON.stringify(submissionError.response.data)}`);
147+
}
148+
if (submissionError.stack) {
149+
platform.logger.debug(`Stack trace: ${submissionError.stack}`);
150+
}
151+
throw submissionError;
152+
}
125153
} catch (error: any) {
126154
platform.logger.setFailed(`Component detection failed: ${error.message}`);
127155
}

component-detection-github-submission-task/index.mjs

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35994,6 +35994,12 @@ function run() {
3599435994
platform.logger.debug(`GitHub Token provided: ${githubToken ? 'Yes' : 'No'}`);
3599535995
// Set the GitHub token in environment for dependency-submission-toolkit
3599635996
process.env.GITHUB_TOKEN = githubToken;
35997+
// Also set other environment variables that the toolkit might expect
35998+
process.env.GITHUB_REPOSITORY = githubRepository;
35999+
process.env.GITHUB_API_URL = 'https://api.github.com';
36000+
// The dependency-submission-toolkit might expect these GitHub Actions environment variables
36001+
process.env.GITHUB_SERVER_URL = 'https://github.com';
36002+
process.env.GITHUB_GRAPHQL_URL = 'https://api.github.com/graphql';
3599736003
let manifests = yield componentDetection_1.default.scanAndGetManifests(platform.input.getInput("filePath") || ".", platform);
3599836004
const correlatorInput = ((_a = platform.input.getInput("correlator")) === null || _a === void 0 ? void 0 : _a.trim()) || platform.context.getJobId();
3599936005
// Get detector configuration inputs
@@ -36059,9 +36065,30 @@ function run() {
3605936065
if (snapshotRef) {
3606036066
snapshot.ref = snapshotRef;
3606136067
}
36068+
if (!manifests || manifests.length === 0) {
36069+
platform.logger.warning("No manifests found. Skipping dependency submission.");
36070+
return;
36071+
}
36072+
platform.logger.info(`Submitting snapshot with ${snapshot.manifests.size} manifests to GitHub repository: ${repo.owner}/${repo.repo}`);
36073+
platform.logger.debug(`Snapshot SHA: ${snapshot.sha}`);
36074+
platform.logger.debug(`Snapshot Ref: ${snapshot.ref}`);
36075+
platform.logger.debug(`Correlator: ${correlatorInput}`);
3606236076
// Submit snapshot to GitHub (using the provided GitHub token)
36063-
yield (0, dependency_submission_toolkit_1.submitSnapshot)(snapshot);
36064-
platform.logger.info("Component detection and dependency submission completed successfully");
36077+
try {
36078+
yield (0, dependency_submission_toolkit_1.submitSnapshot)(snapshot);
36079+
platform.logger.info("Component detection and dependency submission completed successfully");
36080+
}
36081+
catch (submissionError) {
36082+
platform.logger.error(`Failed to submit snapshot to GitHub: ${submissionError.message}`);
36083+
if (submissionError.response) {
36084+
platform.logger.error(`HTTP Status: ${submissionError.response.status}`);
36085+
platform.logger.error(`Response: ${JSON.stringify(submissionError.response.data)}`);
36086+
}
36087+
if (submissionError.stack) {
36088+
platform.logger.debug(`Stack trace: ${submissionError.stack}`);
36089+
}
36090+
throw submissionError;
36091+
}
3606536092
}
3606636093
catch (error) {
3606736094
platform.logger.setFailed(`Component detection failed: ${error.message}`);

component-detection-github-submission-task/task.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"version": {
1010
"Major": 0,
1111
"Minor": 1,
12-
"Patch": 9
12+
"Patch": 10
1313
},
1414
"instanceNameFormat": "Component Detection $(filePath)",
1515
"groups": [

vss-extension.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifestVersion": 1,
33
"id": "component-detection-github-submission-task",
44
"name": "Component Detection for GitHub Dependency Submission",
5-
"version": "0.1.9",
5+
"version": "0.1.10",
66
"publisher": "AdvancedSecurityOSS",
77
"description": "Upload information about your dependencies to the GitHub dependency graph using Microsoft's component detection library",
88
"public": false,

0 commit comments

Comments
 (0)