File tree Expand file tree Collapse file tree
src/distributions/graalvm Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1058,6 +1058,20 @@ describe('GraalVMDistribution', () => {
10581058 'GraalVM Community does not provide early access builds'
10591059 ) ;
10601060 } ) ;
1061+
1062+ it ( 'should surface an error when the releases listing is not an array' , async ( ) => {
1063+ mockHttpClient . getJson . mockResolvedValue ( {
1064+ result : { message : 'API rate limit exceeded' } ,
1065+ statusCode : 403 ,
1066+ headers : { }
1067+ } ) ;
1068+
1069+ await expect (
1070+ ( communityDistribution as any ) . findPackageForDownload ( '21' )
1071+ ) . rejects . toThrow (
1072+ / U n e x p e c t e d r e s p o n s e w h i l e l i s t i n g G r a a l V M C o m m u n i t y r e l e a s e s .* H T T P s t a t u s c o d e : 4 0 3 / s
1073+ ) ;
1074+ } ) ;
10611075 } ) ;
10621076 } ) ;
10631077} ) ;
Original file line number Diff line number Diff line change @@ -79300,7 +79300,17 @@ class GraalVMCommunityDistribution extends GraalVMDistribution {
7930079300 let releasesUrl = GRAALVM_COMMUNITY_RELEASES_URL;
7930179301 for (let pageIndex = 0; releasesUrl && pageIndex < util_1.MAX_PAGINATION_PAGES; pageIndex++) {
7930279302 const response = yield this.http.getJson(releasesUrl, headers);
79303- const releases = Array.isArray(response.result) ? response.result : [];
79303+ // A successful GitHub releases listing is always a JSON array (possibly
79304+ // empty). Anything else indicates an unexpected/error payload (rate
79305+ // limiting, auth failure, etc.) that must be surfaced instead of being
79306+ // silently treated as "no releases", which would later look like a
79307+ // misleading "version not found" error.
79308+ if (!Array.isArray(response.result)) {
79309+ throw new Error(`Unexpected response while listing GraalVM Community releases from ${releasesUrl} ` +
79310+ `(HTTP status code: ${response.statusCode}). Expected a JSON array of releases. ` +
79311+ `Please check if the service is available at ${GRAALVM_COMMUNITY_DOWNLOAD_URL}.`);
79312+ }
79313+ const releases = response.result;
7930479314 if (releases.length === 0) {
7930579315 break;
7930679316 }
Original file line number Diff line number Diff line change @@ -186,8 +186,8 @@ steps:
186186 distribution: 'graalvm-community'
187187 java-version: '21'
188188- run: |
189- java -cp java HelloWorldApp
190- native-image -cp java HelloWorldApp
189+ java --version
190+ native-image --version
191191` ` `
192192
193193# ## JetBrains
Original file line number Diff line number Diff line change @@ -391,7 +391,20 @@ export class GraalVMCommunityDistribution extends GraalVMDistribution {
391391 headers
392392 ) ;
393393
394- const releases = Array . isArray ( response . result ) ? response . result : [ ] ;
394+ // A successful GitHub releases listing is always a JSON array (possibly
395+ // empty). Anything else indicates an unexpected/error payload (rate
396+ // limiting, auth failure, etc.) that must be surfaced instead of being
397+ // silently treated as "no releases", which would later look like a
398+ // misleading "version not found" error.
399+ if ( ! Array . isArray ( response . result ) ) {
400+ throw new Error (
401+ `Unexpected response while listing GraalVM Community releases from ${ releasesUrl } ` +
402+ `(HTTP status code: ${ response . statusCode } ). Expected a JSON array of releases. ` +
403+ `Please check if the service is available at ${ GRAALVM_COMMUNITY_DOWNLOAD_URL } .`
404+ ) ;
405+ }
406+
407+ const releases = response . result ;
395408 if ( releases . length === 0 ) {
396409 break ;
397410 }
You can’t perform that action at this time.
0 commit comments