Skip to content

Commit 03a480b

Browse files
feat: allow-incomplete-sbom support in legacy CLI paths [CSENG-173]
1 parent 0992891 commit 03a480b

2 files changed

Lines changed: 43 additions & 6 deletions

File tree

src/lib/plugins/get-deps-from-plugin.ts

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,37 @@ export async function getDepsFromPlugin(
102102
if (!options.docker && !(options.file || options.packageManager)) {
103103
throw NoSupportedManifestsFoundError([...root]);
104104
}
105-
const inspectRes = await getSinglePluginResult(
106-
root,
107-
options,
108-
'',
109-
featureFlags,
110-
);
105+
let inspectRes;
106+
try {
107+
inspectRes = await getSinglePluginResult(
108+
root,
109+
options,
110+
'',
111+
featureFlags,
112+
);
113+
} catch (error) {
114+
if (options['print-effective-graph-with-errors']) {
115+
const errMessage =
116+
error?.message ?? 'Something went wrong getting dependencies';
117+
debug(
118+
`Single plugin scan failed for ${options.file}, collecting as failed result: ${errMessage}`,
119+
);
120+
return {
121+
plugin: {
122+
name: options.packageManager || 'unknown',
123+
},
124+
scannedProjects: [],
125+
failedResults: [
126+
{
127+
targetFile: options.file,
128+
error,
129+
errMessage,
130+
},
131+
],
132+
} as MultiProjectResultCustom;
133+
}
134+
throw error;
135+
}
111136

112137
if (!pluginApi.isMultiResult(inspectRes)) {
113138
if (!inspectRes.package && !inspectRes.dependencyGraph) {

src/lib/plugins/get-multi-plugin-result.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,18 @@ export async function getMultiPluginResult(
183183
}
184184

185185
if (!allResults.length) {
186+
// When allow-incomplete-sbom is active, return instead of throwing
187+
// so the caller can print per-project JSONL error entries
188+
if (options['print-effective-graph-with-errors']) {
189+
return {
190+
plugin: {
191+
name: 'custom-auto-detect',
192+
},
193+
scannedProjects: allResults,
194+
failedResults,
195+
};
196+
}
197+
186198
// No projects were scanned successfully
187199
let message = `Failed to get dependencies for all ${targetFiles.length} potential projects.\n`;
188200

0 commit comments

Comments
 (0)