Skip to content

Commit

Permalink
Added descriptive error when repo is private or not found during ext:…
Browse files Browse the repository at this point in the history
…dev:upload. (#6052)

* Added more descriptive error message when repo is private (or not found).

* Formatting.

* Formatting.

* Update CHANGELOG.md

---------

Co-authored-by: joehan <joehanley@google.com>
  • Loading branch information
apascal07 and joehan authored Jun 28, 2023
1 parent 893971f commit e1f0d8d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
- Increased extension instance create poll timeout to 1h to match backend (#5969).
- Refactored `ext:install` to use the latest extension metadata. (#5997)
- Added descriptive error when repo is private or not found during `ext:dev:upload`. (#6052)
- Fixed issue where missing trigger warnings would be wrongly displayed when emulating extensions with HTTPS triggers. (#6055)
- Normalized extension root path before usage in `ext:dev:upload`. (#6054)
10 changes: 7 additions & 3 deletions src/extensions/extensionsHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -729,17 +729,21 @@ async function fetchExtensionSource(
logger.info(`Validating source code at ${clc.bold(sourceUri)}...`);
const archiveUri = `${repoUri}/archive/${sourceRef}.zip`;
const tempDirectory = tmp.dirSync({ unsafeCleanup: true });
const archiveErrorMessage = `Failed to extract archive from ${clc.bold(
archiveUri
)}. Please check that the repo is public and that the source ref is valid.`;
try {
const response = await fetch(archiveUri);
if (response.ok) {
await response.body.pipe(createUnzipTransform(tempDirectory.name)).promise();
}
} catch (err: any) {
throw new FirebaseError(
`Failed to fetch extension archive from ${archiveUri}. Please check the repo URI and source ref. ${err}`
);
throw new FirebaseError(archiveErrorMessage);
}
const archiveName = fs.readdirSync(tempDirectory.name)[0];
if (!archiveName) {
throw new FirebaseError(archiveErrorMessage);
}
const rootDirectory = path.join(tempDirectory.name, archiveName, extensionRoot);
// Pre-validation to show a more useful error message in the context of a temp directory.
try {
Expand Down

0 comments on commit e1f0d8d

Please sign in to comment.