Skip to content

feat(apify): add run task, get dataset items, and get run tools#4851

Merged
waleedlatif1 merged 2 commits into
stagingfrom
waleedlatif1/apify-integration-validation
Jun 2, 2026
Merged

feat(apify): add run task, get dataset items, and get run tools#4851
waleedlatif1 merged 2 commits into
stagingfrom
waleedlatif1/apify-integration-validation

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

Summary

  • Add three Apify tools: apify_run_task, apify_get_dataset_items, apify_get_run
  • Wire new operations into the Apify block with conditional required fields and advanced-mode tuning params
  • Switch all tools to header-only Authorization: Bearer auth (drop redundant ?token= query param), trim path IDs, and remove any casts via a typed ApifyRun interface
  • Set authMode: AuthMode.ApiKey on the block

Type of Change

  • New feature

Testing

Tested manually; biome lint clean.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jun 2, 2026 7:28pm

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented Jun 2, 2026

PR Summary

Medium Risk
Touches external Apify HTTP calls and removes query-token auth on existing actor tools, which could break deployments that relied on ?token=; API keys still flow through workflow params as before.

Overview
Expands the Apify integration from two actor-run operations to five, adding Run Task, Get Dataset Items, and Get Run so workflows can run saved tasks, paginate/filter datasets, and inspect runs without always starting a new actor.

The Apify block gains operation-specific fields (taskId, datasetId, runId), conditional required inputs, AuthMode.ApiKey, and several tuning fields moved to advanced mode. Docs and the integrations catalog are updated to match (operationCount 2 → 5).

Existing sync/async actor tools now authenticate with Authorization: Bearer only (no ?token= on URLs), trim actor/task/dataset/run IDs in paths, and the async tool polls /v2/actor-runs/{runId} with typed ApifyRun responses instead of passing the API key in query strings.

Reviewed by Cursor Bugbot for commit 6282a90. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jun 2, 2026

Greptile Summary

This PR extends the Apify integration with three new tools (apify_run_task, apify_get_dataset_items, apify_get_run), migrates all Apify tools from ?token= query-param auth to Authorization: Bearer header-only auth, and tightens the type model by exporting a shared ApifyRun interface with properly optional fields.

  • Three new tools wired end-to-end: run_task runs a saved task synchronously and returns dataset items; get_dataset_items fetches items from an existing dataset with offset != null guard for correct zero-offset handling; get_run retrieves full run metadata.
  • Auth cleanup: redundant ?token= query parameter removed from all URL builders; the Bearer header alone is now the only credential path.
  • Block updated: new operations added with per-operation conditional field visibility, advanced-mode tuning params, and authMode: AuthMode.ApiKey.

Confidence Score: 5/5

Safe to merge — all three new tools are well-contained additions with proper error handling, and the auth migration is a straightforward header-only change with no regressions.

The new tools follow the same patterns as existing Apify tools, the body/input handling in run_task.ts is consistent with run_actor_sync.ts, the dataset-fetch guard and offset null-check from prior review rounds are correctly applied, and the polling URL simplification in run_actor_async.ts is a clean improvement.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/tools/apify/run_task.ts New synchronous task runner. Body pattern (returning {} when no input) is consistent with run_actor_sync.ts. itemLimit is clamped, URL is encoded and trimmed.
apps/sim/tools/apify/get_dataset_items.ts New dataset-fetch tool. offset uses != null guard, itemLimit properly clamped to 1-250000, clean=true set for filtered results.
apps/sim/tools/apify/get_run.ts New run-status tool. Uses typed ApifyRun cast, all nullable fields handled with ?? null.
apps/sim/tools/apify/run_actor_async.ts Removed ?token= query param, added .trim() on actorId, guarded dataset fetch with run.defaultDatasetId presence check.
apps/sim/blocks/blocks/apify.ts Conditional field visibility, per-operation required guards, authMode added, offset forwarded with strict null/empty check.
apps/sim/tools/apify/types.ts ApifyRun exported as shared interface with properly optional fields; new param/result interfaces for three new tools.

Sequence Diagram

sequenceDiagram
    participant U as User/Agent
    participant B as Apify Block
    participant T as Tool Dispatcher
    participant A as Apify API

    Note over U,A: apify_run_task
    U->>B: "operation=apify_run_task, taskId, input?"
    B->>T: params(taskId, apiKey, input?, itemLimit?)
    T->>A: "POST /v2/actor-tasks/{taskId}/run-sync-get-dataset-items"
    A-->>T: 200 items[]
    T-->>U: "{success, status, items[]}"

    Note over U,A: apify_get_dataset_items
    U->>B: "operation=apify_get_dataset_items, datasetId"
    B->>T: params(datasetId, itemLimit?, offset?, fields?)
    T->>A: "GET /v2/datasets/{datasetId}/items?clean=true"
    A-->>T: 200 items[]
    T-->>U: "{success, datasetId, items[], count}"

    Note over U,A: apify_get_run
    U->>B: "operation=apify_get_run, runId"
    B->>T: params(runId, apiKey)
    T->>A: "GET /v2/actor-runs/{runId}"
    A-->>T: "200 {data: ApifyRun}"
    T-->>U: "{success, runId, status, startedAt, finishedAt, datasetId, stats}"
Loading

Reviews (2): Last reviewed commit: "fix(apify): guard undefined dataset id a..." | Re-trigger Greptile

Comment thread apps/sim/tools/apify/run_actor_async.ts Outdated
Comment thread apps/sim/tools/apify/get_dataset_items.ts Outdated
Comment thread apps/sim/blocks/blocks/apify.ts Outdated
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 6282a90. Configure here.

@waleedlatif1 waleedlatif1 merged commit e2c2d9a into staging Jun 2, 2026
14 checks passed
@waleedlatif1 waleedlatif1 deleted the waleedlatif1/apify-integration-validation branch June 2, 2026 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant