Return toolcache rejection reasons with Result

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Henry Mercer
2026-09-16 19:43:05 +01:00
parent bd2ddba96c
commit 89606bbad1
3 changed files with 66 additions and 40 deletions

37
lib/entry-points.js generated
View File

@@ -152541,8 +152541,8 @@ var downloadCodeQL = async function(source, apiDetails, tarVersion, tempDir, log
codeqlURL
);
}
const toolcacheDestination = getToolcacheDestination(source, logger);
const extractedBundlePath = toolcacheDestination ?? getTempExtractionDir(tempDir);
const toolcacheDestination = getToolcacheDestination({ logger }, source);
const extractedBundlePath = toolcacheDestination.isSuccess() ? toolcacheDestination.value : getTempExtractionDir(tempDir);
const statusReport = await downloadAndExtract(
codeqlURL,
compressionMethod,
@@ -152552,27 +152552,34 @@ var downloadCodeQL = async function(source, apiDetails, tarVersion, tempDir, log
tarVersion,
logger
);
if (toolcacheDestination) {
writeToolcacheMarkerFile(toolcacheDestination, logger);
if (toolcacheDestination.isSuccess()) {
writeToolcacheMarkerFile(toolcacheDestination.value, logger);
} else {
logger.debug(
bundle.kind === "per-language" ? "Not caching the CodeQL tools because they came from a bundle that contains only a single language." : `Could not cache CodeQL tools because we could not determine the bundle version from the URL ${codeqlURL}.`
);
logger.debug(toolcacheDestination.value);
}
return {
codeqlFolder: extractedBundlePath,
statusReport: bundle.kind === "per-language" ? { ...statusReport, bundleLanguage: bundle.language } : statusReport
};
};
function getToolcacheDestination(source, logger) {
if (source.bundle.kind !== "combined" || !source.bundleVersion) {
return void 0;
function getToolcacheDestination({ logger }, source) {
if (source.bundle.kind !== "combined") {
return new Failure(
"Not caching the CodeQL tools because they came from a bundle that contains only a single language."
);
}
return getToolcacheDirectory(
getCanonicalToolcacheVersion(
source.cliVersion,
source.bundleVersion,
logger
if (!source.bundleVersion) {
return new Failure(
`Could not cache CodeQL tools because we could not determine the bundle version from the URL ${source.bundle.url}.`
);
}
return new Success(
getToolcacheDirectory(
getCanonicalToolcacheVersion(
source.cliVersion,
source.bundleVersion,
logger
)
)
);
}