Skip to content

Commit 98db1cf

Browse files
authored
chore: bail out early for actors pull with hidden source code actors (#888)
1 parent a1e9982 commit 98db1cf

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/commands/actors/pull.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,12 @@ export class ActorsPullCommand extends ApifyCommand<typeof ActorsPullCommand> {
9191

9292
const { name, versions } = actor;
9393

94-
// @ts-expect-error TODO: fix apify-client types
95-
if (actor.isSourceCodeHidden && !actor.versions.length) {
94+
const throwMissingSourceCodeAccessError = () => {
9695
throw new Error(`You cannot pull source code of this Actor because you do not have permission to do so.`);
96+
};
97+
98+
if (!actor.versions.length) {
99+
throw new Error(`Actor ${actorId} has no versions.`);
97100
}
98101

99102
let correctVersion = null;
@@ -121,11 +124,19 @@ export class ActorsPullCommand extends ApifyCommand<typeof ActorsPullCommand> {
121124

122125
switch (correctVersion.sourceType) {
123126
case 'TARBALL': {
127+
if (!correctVersion.tarballUrl) {
128+
throwMissingSourceCodeAccessError();
129+
}
130+
124131
await extractGitHubZip(correctVersion.tarballUrl, dirpath);
125132

126133
break;
127134
}
128135
case 'SOURCE_FILES': {
136+
if (!correctVersion.sourceFiles) {
137+
throwMissingSourceCodeAccessError();
138+
}
139+
129140
const { sourceFiles } = correctVersion;
130141
for (const file of sourceFiles) {
131142
const folderPath = dirname(file.name);
@@ -150,6 +161,10 @@ export class ActorsPullCommand extends ApifyCommand<typeof ActorsPullCommand> {
150161
}
151162
case 'GIT_REPO': {
152163
// e.g. https://github.com/jakubbalada/Datasety.git#master:RejstrikPolitickychStran
164+
if (!correctVersion.gitRepoUrl) {
165+
throwMissingSourceCodeAccessError();
166+
}
167+
153168
const { gitRepoUrl } = correctVersion;
154169
const [repoUrl, branchDirPart] = gitRepoUrl.split('#');
155170

@@ -170,6 +185,10 @@ export class ActorsPullCommand extends ApifyCommand<typeof ActorsPullCommand> {
170185
break;
171186
}
172187
case 'GITHUB_GIST': {
188+
if (!correctVersion.gitHubGistUrl) {
189+
throwMissingSourceCodeAccessError();
190+
}
191+
173192
await extractGitHubZip(`${correctVersion.gitHubGistUrl}/archive/master.zip`, dirpath);
174193

175194
break;

0 commit comments

Comments
 (0)