From 547d0a1390bac0f09ca1fd42267fcdbd51212b12 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 18 Aug 2020 12:08:38 +0200 Subject: [PATCH] auth-backend: nicer error message for missing env query --- plugins/auth-backend/src/lib/EnvironmentHandler.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/auth-backend/src/lib/EnvironmentHandler.ts b/plugins/auth-backend/src/lib/EnvironmentHandler.ts index fb39ed86b8..53e56a7420 100644 --- a/plugins/auth-backend/src/lib/EnvironmentHandler.ts +++ b/plugins/auth-backend/src/lib/EnvironmentHandler.ts @@ -19,6 +19,7 @@ import { AuthProviderRouteHandlers, EnvironmentIdentifierFn, } from '../providers/types'; +import { InputError } from '@backstage/backend-common'; export type EnvironmentHandlers = { [key: string]: AuthProviderRouteHandlers; @@ -37,7 +38,11 @@ export class EnvironmentHandler implements AuthProviderRouteHandlers { ): AuthProviderRouteHandlers | undefined { const env: string | undefined = this.envIdentifier(req); - if (env && this.providers.hasOwnProperty(env)) { + if (!env) { + throw new InputError(`Must specify 'env' query to select environment`); + } + + if (this.providers.hasOwnProperty(env)) { return this.providers[env]; }