diff --git a/.changeset/blue-snakes-compete.md b/.changeset/blue-snakes-compete.md new file mode 100644 index 0000000000..73054554b1 --- /dev/null +++ b/.changeset/blue-snakes-compete.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-adr-backend': patch +--- + +Continue processing subsequent entities when an error occurs in collator diff --git a/.changeset/witty-queens-happen.md b/.changeset/witty-queens-happen.md new file mode 100644 index 0000000000..969bd2c79e --- /dev/null +++ b/.changeset/witty-queens-happen.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-adr': patch +--- + +Fix parsing of ADR location which includes a trailing slash diff --git a/plugins/adr-backend/src/search/DefaultAdrCollatorFactory.ts b/plugins/adr-backend/src/search/DefaultAdrCollatorFactory.ts index 811b52ba82..21f0f1945f 100644 --- a/plugins/adr-backend/src/search/DefaultAdrCollatorFactory.ts +++ b/plugins/adr-backend/src/search/DefaultAdrCollatorFactory.ts @@ -30,7 +30,7 @@ import { } from '@backstage/catalog-client'; import { stringifyEntityRef } from '@backstage/catalog-model'; import { Config } from '@backstage/config'; -import { NotModifiedError } from '@backstage/errors'; +import { NotModifiedError, stringifyError } from '@backstage/errors'; import { ScmIntegrationRegistry, ScmIntegrations, @@ -155,9 +155,9 @@ export class DefaultAdrCollatorFactory implements DocumentCollatorFactory { adrsUrl = getAdrLocationUrl(ent, this.scmIntegrations); } catch (e: any) { this.logger.error( - `Unable to get ADR location URL for ${stringifyEntityRef(ent)}: ${ - e.message - }`, + `Unable to get ADR location URL for ${stringifyEntityRef( + ent, + )}: ${stringifyError(e)}`, ); continue; } @@ -190,7 +190,10 @@ export class DefaultAdrCollatorFactory implements DocumentCollatorFactory { } catch (error: any) { // Ignore error if we're able to use cached response if (!cacheItem || error.name !== NotModifiedError.name) { - throw error; + this.logger.error( + `Unable to fetch ADRs from ${adrsUrl}: ${stringifyError(error)}`, + ); + continue; } } @@ -203,7 +206,9 @@ export class DefaultAdrCollatorFactory implements DocumentCollatorFactory { }); yield adrDoc; } catch (e: any) { - this.logger.error(`Unable to parse ADR ${path}: ${e.message}`); + this.logger.error( + `Unable to parse ADR ${path}: ${stringifyError(e)}`, + ); } } diff --git a/plugins/adr/src/components/AdrReader/AdrReader.tsx b/plugins/adr/src/components/AdrReader/AdrReader.tsx index 3667d8fd8c..971dae0949 100644 --- a/plugins/adr/src/components/AdrReader/AdrReader.tsx +++ b/plugins/adr/src/components/AdrReader/AdrReader.tsx @@ -45,7 +45,7 @@ export const AdrReader = (props: { const adrLocationUrl = getAdrLocationUrl(entity, scmIntegrations); const { value, loading, error } = useOctokitRequest( - `${adrLocationUrl}/${adr}`, + `${adrLocationUrl.replace(/\/$/, '')}/${adr}`, ); const adrContent = useMemo(() => {