diff --git a/packages/core/http/core-http-router-server-internal/src/versioned_router/core_versioned_route.test.ts b/packages/core/http/core-http-router-server-internal/src/versioned_router/core_versioned_route.test.ts index 89f567160f81a..43af728b36a53 100644 --- a/packages/core/http/core-http-router-server-internal/src/versioned_router/core_versioned_route.test.ts +++ b/packages/core/http/core-http-router-server-internal/src/versioned_router/core_versioned_route.test.ts @@ -193,7 +193,7 @@ describe('Versioned route', () => { ).resolves.toEqual( expect.objectContaining({ payload: - 'No version "999" available for [post] [/test/{id}]. Available versions are: "none"', + 'No version "999" available for [post] [/test/{id}]. Available versions are: ', status: 406, }) ); @@ -212,7 +212,7 @@ describe('Versioned route', () => { handler!({} as any, createRequest({ version: undefined }), responseFactory) ).resolves.toEqual({ options: {}, - payload: `Version expected at [post] [/test/{id}]. Please specify a version using the "${ELASTIC_HTTP_VERSION_HEADER}" header. Available versions are: "1"`, + payload: `Version expected at [post] [/test/{id}]. Please specify a version using the "${ELASTIC_HTTP_VERSION_HEADER}" header. Available versions are: [1]`, status: 406, }); }); diff --git a/packages/core/http/core-http-router-server-internal/src/versioned_router/core_versioned_route.ts b/packages/core/http/core-http-router-server-internal/src/versioned_router/core_versioned_route.ts index dffa394191ce8..4eafc5d54bde0 100644 --- a/packages/core/http/core-http-router-server-internal/src/versioned_router/core_versioned_route.ts +++ b/packages/core/http/core-http-router-server-internal/src/versioned_router/core_versioned_route.ts @@ -77,7 +77,10 @@ export class CoreVersionedRoute implements VersionedRoute { } private getAvailableVersionsMessage(): string { - return `Available versions are: "${[...this.handlers.keys()].join(',') || 'none'}"`; + const versions = [...this.handlers.keys()]; + return `Available versions are: ${ + versions.length ? '[' + [...versions].join(', ') + ']' : '' + }`; } /** This is where we must implement the versioned spec once it is available */ diff --git a/src/core/server/integration_tests/http/versioned_router.test.ts b/src/core/server/integration_tests/http/versioned_router.test.ts index 2e7b2cbd7930e..b2179bea4d1f7 100644 --- a/src/core/server/integration_tests/http/versioned_router.test.ts +++ b/src/core/server/integration_tests/http/versioned_router.test.ts @@ -101,8 +101,7 @@ describe('Routing versioned requests', () => { .then(({ body }) => body) ).resolves.toEqual( expect.objectContaining({ - message: - 'Version expected at [get] [/my-path]. Please specify a version using the "elastic-api-version" header. Available versions are: "1,2"', + message: expect.stringMatching(/Version expected at/), }) ); });