catalog-backend: module connect error tweaks

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2026-01-25 12:24:34 +01:00
parent 30c40523fa
commit 51e0f0d61c
3 changed files with 20 additions and 6 deletions
@@ -27,7 +27,7 @@ import {
EntityProviderMutation,
} from '@backstage/plugin-catalog-node';
import type { ExtensionPointFactoryContext } from '@backstage/backend-plugin-api';
import { assertError } from '@backstage/errors';
import { ForwardedError } from '@backstage/errors';
export type EntityProviderEntry = {
provider: EntityProvider;
@@ -118,8 +118,12 @@ export async function connectEntityProviders(
await provider.connect(connection);
} catch (error: unknown) {
if (context) {
assertError(error);
context.reportModuleStartupFailure({ error });
context.reportModuleStartupFailure({
error: new ForwardedError(
`Failed to connect entity provider '${provider.getProviderName()}'`,
error,
),
});
return;
}
throw error;
@@ -151,6 +151,8 @@ export type CatalogEnvironment = {
* - Processors can be added or replaced. These implement the functionality of
* reading, parsing, validating, and processing the entity data before it is
* persisted in the catalog.
*
* @internal
*/
export class CatalogBuilder {
private readonly env: CatalogEnvironment;
@@ -20,7 +20,7 @@ import {
stringifyEntityRef,
} from '@backstage/catalog-model';
import { ConfigReader } from '@backstage/config';
import { InputError } from '@backstage/errors';
import { InputError, NotImplementedError } from '@backstage/errors';
import { ScmIntegrations } from '@backstage/integration';
import { LocationSpec } from '@backstage/plugin-catalog-common';
import {
@@ -321,7 +321,11 @@ class TestHarness {
providerDatabase,
providers.map(p => ({
provider: p,
context: { reportModuleStartupFailure: jest.fn() },
context: {
reportModuleStartupFailure: () => {
throw new NotImplementedError();
},
},
})),
);
@@ -557,7 +561,11 @@ describe('Catalog Backend Integration', () => {
},
]),
).resolves.toBeUndefined();
expect(reportFailure).toHaveBeenCalledWith({ error });
expect(reportFailure).toHaveBeenCalledWith({
error: new Error(
"Failed to connect entity provider 'failing'; caused by Error: NOPE",
),
});
});
it('should orphan entities', async () => {