Skip to content
Merged
Prev Previous commit
Next Next commit
fix(graalvm): improve error messages for version not found scenarios …
…with updated download URL
  • Loading branch information
chiranjib-swain committed Apr 2, 2026
commit eed22b7e19a3a5cb00cb70e07b44c57221010506
10 changes: 6 additions & 4 deletions __tests__/distributors/graalvm-installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,14 +356,16 @@ describe('GraalVMDistribution', () => {
// Verify the error is thrown with the expected message
await expect(
(distribution as any).findPackageForDownload('17.0.99')
).rejects.toThrow(
"No matching GraalVM version found for SemVer '17.0.99'. Available versions can be found at https://download.oracle.com/graalvm/. Pick a version from the list."
);
).rejects.toThrow("No matching version found for SemVer '17.0.99'");
// Verify distribution info is included
await expect(
(distribution as any).findPackageForDownload('17.0.99')
).rejects.toThrow('GraalVM');

// Verify the hint about checking the base URL is included
await expect(
(distribution as any).findPackageForDownload('17.0.99')
).rejects.toThrow('https://download.oracle.com/graalvm');
).rejects.toThrow('https://www.graalvm.org/downloads/');
});

it('should throw error for unauthorized access (401)', async () => {
Expand Down
8 changes: 5 additions & 3 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113139,6 +113139,7 @@ const base_installer_1 = __nccwpck_require__(59741);
const http_client_1 = __nccwpck_require__(96255);
const util_1 = __nccwpck_require__(92629);
const GRAALVM_DL_BASE = 'https://download.oracle.com/graalvm';
const GRAALVM_DOWNLOAD_URL = 'https://www.graalvm.org/downloads/';
const IS_WINDOWS = process.platform === 'win32';
const GRAALVM_PLATFORM = IS_WINDOWS ? 'windows' : process.platform;
const GRAALVM_MIN_VERSION = 17;
Expand Down Expand Up @@ -113217,9 +113218,10 @@ class GraalVMDistribution extends base_installer_1.JavaBase {
handleHttpResponse(response, range) {
const statusCode = response.message.statusCode;
if (statusCode === http_client_1.HttpCodes.NotFound) {
throw new Error(`No matching GraalVM version found for SemVer '${range}'.` +
` Available versions can be found at ${GRAALVM_DL_BASE}/.` +
` Pick a version from the list.`);
// Create the standard error with additional hint about checking the download URL
const error = this.createVersionNotFoundError(range);
error.message += `\nPlease check if this version is available at ${GRAALVM_DOWNLOAD_URL} . Pick a version from the list.`;
throw error;
}
if (statusCode === http_client_1.HttpCodes.Unauthorized ||
statusCode === http_client_1.HttpCodes.Forbidden) {
Expand Down
10 changes: 5 additions & 5 deletions src/distributions/graalvm/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
} from '../../util';

const GRAALVM_DL_BASE = 'https://download.oracle.com/graalvm';
const GRAALVM_DOWNLOAD_URL = 'https://www.graalvm.org/downloads/';
const IS_WINDOWS = process.platform === 'win32';
const GRAALVM_PLATFORM = IS_WINDOWS ? 'windows' : process.platform;
const GRAALVM_MIN_VERSION = 17;
Expand Down Expand Up @@ -149,11 +150,10 @@ export class GraalVMDistribution extends JavaBase {
const statusCode = response.message.statusCode;

if (statusCode === HttpCodes.NotFound) {
throw new Error(
`No matching GraalVM version found for SemVer '${range}'.` +
` Available versions can be found at ${GRAALVM_DL_BASE}/.` +
` Pick a version from the list.`
);
// Create the standard error with additional hint about checking the download URL
const error = this.createVersionNotFoundError(range);
error.message += `\nPlease check if this version is available at ${GRAALVM_DOWNLOAD_URL} . Pick a version from the list.`;
throw error;
}

if (
Expand Down
Loading