Skip to content

Commit efd7308

Browse files
authored
fix(pull): handle private actors correctly (#865)
1 parent 0e63480 commit efd7308

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/commands/actors/pull.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,17 @@ export class ActorsPullCommand extends ApifyCommand<typeof ActorsPullCommand> {
8585
throw new Error(`Cannot find Actor with ID/name '${actorId}' in your account.`);
8686
}
8787

88-
if (!actor) throw new Error(`Cannot find Actor with ID/name '${actorId}' in your account.`);
88+
if (!actor) {
89+
throw new Error(`Cannot find Actor with ID/name '${actorId}' in your account.`);
90+
}
8991

9092
const { name, versions } = actor;
9193

94+
// @ts-expect-error TODO: fix apify-client types
95+
if (actor.isSourceCodeHidden && !actor.versions.length) {
96+
throw new Error(`You cannot pull source code of this Actor because you do not have permission to do so.`);
97+
}
98+
9299
let correctVersion = null;
93100
if (this.flags.version) {
94101
correctVersion = versions.find((version) => version.versionNumber === this.flags.version);

test/api/commands/pull.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,4 +217,12 @@ describe('[api] apify pull', () => {
217217

218218
expect(exists).to.be.eql(true);
219219
});
220+
221+
it('should fail if actor is private', async () => {
222+
await testRunCommand(ActorsPullCommand, { args_actorId: 'apify/website-content-crawler' });
223+
224+
expect(lastErrorMessage()).toMatch(
225+
/You cannot pull source code of this Actor because you do not have permission to do so./i,
226+
);
227+
});
220228
});

0 commit comments

Comments
 (0)