diff --git a/.changeset/forty-dancers-argue.md b/.changeset/forty-dancers-argue.md new file mode 100644 index 0000000000..0b30189e88 --- /dev/null +++ b/.changeset/forty-dancers-argue.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-import': patch +--- + +Update the wording for unknown URLs in the import flow diff --git a/plugins/catalog-import/src/api/CatalogImportClient.test.ts b/plugins/catalog-import/src/api/CatalogImportClient.test.ts index c81adfa68e..5187ffab52 100644 --- a/plugins/catalog-import/src/api/CatalogImportClient.test.ts +++ b/plugins/catalog-import/src/api/CatalogImportClient.test.ts @@ -167,7 +167,11 @@ describe('CatalogImportClient', () => { catalogImportClient.analyzeUrl( 'https://github.com/backstage/backstage', ), - ).rejects.toThrow(new Error('Invalid url')); + ).rejects.toThrow( + new Error( + 'This URL was not recognized as a valid GitHub URL because there was no configured integration that matched the given host name. You could try to paste the full URL to a catalog-info.yaml file instead.', + ), + ); }); it('should find locations from github', async () => { diff --git a/plugins/catalog-import/src/api/CatalogImportClient.ts b/plugins/catalog-import/src/api/CatalogImportClient.ts index c4f50efbd4..ccf16e00f1 100644 --- a/plugins/catalog-import/src/api/CatalogImportClient.ts +++ b/plugins/catalog-import/src/api/CatalogImportClient.ts @@ -73,32 +73,33 @@ export class CatalogImportClient implements CatalogImportApi { } const ghConfig = getGithubIntegrationConfig(this.configApi, url); + if (!ghConfig) { + throw new Error( + 'This URL was not recognized as a valid GitHub URL because there was no configured integration that matched the given host name. You could try to paste the full URL to a catalog-info.yaml file instead.', + ); + } - if (ghConfig) { - // TODO: this could be part of the analyze-location endpoint - const locations = await this.checkGitHubForExistingCatalogInfo({ - ...ghConfig, - url, - }); - - if (locations.length > 0) { - return { - type: 'locations', - locations, - }; - } + // TODO: this could be part of the analyze-location endpoint + const locations = await this.checkGitHubForExistingCatalogInfo({ + ...ghConfig, + url, + }); + if (locations.length > 0) { return { - type: 'repository', - integrationType: 'github', - url: url, - generatedEntities: await this.generateEntityDefinitions({ - repo: url, - }), + type: 'locations', + locations, }; } - throw new Error('Invalid url'); + return { + type: 'repository', + integrationType: 'github', + url: url, + generatedEntities: await this.generateEntityDefinitions({ + repo: url, + }), + }; } async submitPullRequest({