Merge pull request #24862 from elaine-mattos/fix/org-config-key-handling

Bugfix: handle missing orgEnabled config key gracefully
This commit is contained in:
Vincenzo Scamporlino
2024-05-22 12:43:27 +02:00
committed by GitHub
3 changed files with 15 additions and 9 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-backend-module-gitlab': patch
---
Fixed an issue in `GitlabOrgDiscoveryEntityProvider` where a missing `orgEnabled` config key was throwing an error.
@@ -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', () => {
@@ -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) {