diff --git a/.changeset/good-flowers-promise.md b/.changeset/good-flowers-promise.md new file mode 100644 index 0000000000..659c1ab48e --- /dev/null +++ b/.changeset/good-flowers-promise.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-techdocs-backend': patch +--- + +Modified response when catalog entity isn't found to resolve issue where `/sync` endpoint was continuously called diff --git a/plugins/techdocs-backend/src/service/router.ts b/plugins/techdocs-backend/src/service/router.ts index b99579e0eb..4d5ba0ebf3 100644 --- a/plugins/techdocs-backend/src/service/router.ts +++ b/plugins/techdocs-backend/src/service/router.ts @@ -242,14 +242,14 @@ export async function createRouter( targetPluginId: 'catalog', }); - const entity = await entityLoader.load({ kind, namespace, name }, token); - - if (!entity?.metadata?.uid) { - throw new NotFoundError('Entity metadata UID missing'); - } - const responseHandler: DocsSynchronizerSyncOpts = createEventStream(res); + const entity = await entityLoader.load({ kind, namespace, name }, token); + if (!entity?.metadata?.uid) { + responseHandler.error(new NotFoundError('Entity metadata UID missing')); + return; + } + // By default, techdocs-backend will only try to build documentation for an entity if techdocs.builder is set to // 'local'. If set to 'external', it will assume that an external process (e.g. CI/CD pipeline // of the repository) is responsible for building and publishing documentation to the storage provider.