fix: handle missing orgEnabled config key gracefully by logging and returning early. Fixes #24857
Signed-off-by: ElaineDeMattosSilvaB <elaine.de-mattos-silva-bezerra@deutschebahn.com>
This commit is contained in:
+7
-7
@@ -75,16 +75,16 @@ describe('GitlabOrgDiscoveryEntityProvider - configuration', () => {
|
||||
}).toThrow('No gitlab integration found that matches host example.com');
|
||||
});
|
||||
|
||||
it('should throw error when org configuration not found', () => {
|
||||
it('should log a message and return when org configuration not found', () => {
|
||||
const schedule = new PersistingTaskRunner();
|
||||
const config = new ConfigReader(mock.config_no_org_integration);
|
||||
|
||||
expect(() => {
|
||||
GitlabOrgDiscoveryEntityProvider.fromConfig(config, {
|
||||
logger,
|
||||
schedule,
|
||||
});
|
||||
}).toThrow('Org not enabled for test-id');
|
||||
GitlabOrgDiscoveryEntityProvider.fromConfig(config, {
|
||||
logger,
|
||||
schedule,
|
||||
});
|
||||
|
||||
expect(logger.info).toHaveBeenCalledWith('Org not enabled for test-id.');
|
||||
});
|
||||
|
||||
it('should throw error when saas without group configuration', () => {
|
||||
|
||||
+3
-2
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { LoggerService } from '@backstage/backend-plugin-api';
|
||||
import { PluginTaskScheduler, TaskRunner } from '@backstage/backend-tasks';
|
||||
import {
|
||||
ANNOTATION_LOCATION,
|
||||
@@ -28,7 +29,6 @@ import {
|
||||
import { EventsService } from '@backstage/plugin-events-node';
|
||||
import { merge } from 'lodash';
|
||||
import * as uuid from 'uuid';
|
||||
import { LoggerService } from '@backstage/backend-plugin-api';
|
||||
|
||||
import {
|
||||
GitLabClient,
|
||||
@@ -133,7 +133,8 @@ export class GitlabOrgDiscoveryEntityProvider implements EntityProvider {
|
||||
const integration = integrations.byHost(providerConfig.host);
|
||||
|
||||
if (!providerConfig.orgEnabled) {
|
||||
throw new Error(`Org not enabled for ${providerConfig.id}.`);
|
||||
options.logger.info(`Org not enabled for ${providerConfig.id}.`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!integration) {
|
||||
|
||||
Reference in New Issue
Block a user