Skip to content

Improve Apify actions #16384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Improve Apify actions #16384

wants to merge 4 commits into from

Conversation

michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented Apr 21, 2025

Resolves #16305

Summary by CodeRabbit

  • New Features

    • Default values are now displayed in property descriptions and assigned for supported types in the "Run Actor" action, improving clarity when configuring properties.
    • Added support for running actors asynchronously with new options for timeout, memory, max items, total charge limits, and webhooks.
    • Introduced a "Build" selector to specify actor builds when running actors.
    • Added new methods to run actors synchronously or asynchronously via updated APIs.
  • Bug Fixes

    • The "Run Actor" feature now uses a synchronous API endpoint for improved request handling.
  • Chores

    • Updated version numbers for several actions, sources, and the package to reflect recent changes.
    • Clarified actor ID format descriptions for better user understanding.

Copy link

vercel bot commented Apr 21, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Ignored (Inspect) Visit Preview Apr 23, 2025 6:13pm
pipedream-docs ⬜️ Ignored (Inspect) Apr 23, 2025 6:13pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Apr 23, 2025 6:13pm

Copy link
Contributor

coderabbitai bot commented Apr 21, 2025

Walkthrough

This set of changes primarily updates version numbers across several Apify actions, sources, and the package metadata. In addition, the runActor method in apify.app.mjs now targets the /run-sync endpoint instead of /runs. The run-actor action also receives a logic update: when constructing additional properties, default values from the schema are now included in the property descriptors (except for object types), and descriptions are updated to mention default values. New optional props such as buildId, runAsynchronously, timeout, memory, maxItems, maxTotalChargeUsd, and webhook are added. The run method conditionally calls synchronous or asynchronous actor run endpoints with these parameters. No other functional or structural changes are present.

Changes

Files / Paths Change Summary
components/apify/actions/get-dataset-items/get-dataset-items.mjs Version updated from 0.0.1 to 0.0.2.
components/apify/actions/run-actor/run-actor.mjs Version updated from 0.0.2 to 0.0.3; added props: buildId, runAsynchronously, timeout, memory, maxItems, maxTotalChargeUsd, webhook; getSchema and prepareData updated to use buildId; additionalProps now include default values in descriptions and assign defaults except for objects; run method updated to conditionally call synchronous or asynchronous actor run endpoints with new parameters.
components/apify/actions/run-task-synchronously/run-task-synchronously.mjs Version updated from 0.0.1 to 0.0.2.
components/apify/actions/scrape-single-url/scrape-single-url.mjs Version updated from 0.0.2 to 0.0.3.
components/apify/actions/set-key-value-store-record/set-key-value-store-record.mjs Version updated from 0.0.2 to 0.0.3.
components/apify/apify.app.mjs Added buildId prop with async options method; updated actorId description; added runActor method calling /run-sync; added runActorAsynchronously method calling /runs; listBuilds signature updated to accept object parameter.
components/apify/package.json Package version updated from 0.2.0 to 0.2.1.
components/apify/sources/new-finished-actor-run-instant/new-finished-actor-run-instant.mjs Version updated from 0.0.2 to 0.0.3.
components/apify/sources/new-finished-task-run-instant/new-finished-task-run-instant.mjs Version updated from 0.0.2 to 0.0.3.
components/apify/common/constants.mjs Added new constant EVENT_TYPES array enumerating actor run lifecycle event types.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant RunActorAction
    participant ApifyApp

    User->>RunActorAction: Invoke Run Actor action
    RunActorAction->>ApifyApp: Call runActor({ actorId, buildId, ...opts }) or runActorAsynchronously(...)
    ApifyApp->>Apify API: POST /acts/${actorId}/run-sync (sync) or /acts/${actorId}/runs (async)
    Apify API-->>ApifyApp: Return run result or run ID
    ApifyApp-->>RunActorAction: Return result or run info
    RunActorAction-->>User: Return result or summary message
Loading

Assessment against linked issues

Objective Addressed Explanation
Ensure Run Actor action returns expected results, possibly using synchronous endpoint (#16305)
Correct handling of additionalProps optionality and default values in Run Actor action (#16305)

Possibly related PRs

Suggested reviewers

  • GTFalcao

Poem

In the fields of Apify, versions hop anew,
Actions and sources now wear a shinier hue.
With defaults in place and sync calls in tow,
RunActor’s smarter—just thought you should know!
🐇✨
Version bumps abound, the code hops on,
Another bright update—now bugs be gone!

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

components/apify/actions/run-actor/run-actor.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)

components/apify/common/constants.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9b61d71 and a2c74af.

📒 Files selected for processing (2)
  • components/apify/actions/run-actor/run-actor.mjs (5 hunks)
  • components/apify/common/constants.mjs (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • components/apify/common/constants.mjs
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/apify/actions/run-actor/run-actor.mjs
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: pnpm publish
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Lint Code Base

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

luancazarine
luancazarine previously approved these changes Apr 21, 2025
Copy link
Collaborator

@luancazarine luancazarine left a comment

Choose a reason for hiding this comment

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

Hi @michelle0927, LGTM! Ready for QA!

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (1)
components/apify/actions/run-actor/run-actor.mjs (1)

84-93: ⚠️ Potential issue

Potential runtime crash if schema lacks the keyed property

prepareData() assumes every key present in data exists in the actor’s input schema:

const editor = properties[key].editor;

If the user supplies an extra property, or the schema was updated and a field was removed, properties[key] is undefined, leading to TypeError: Cannot read property 'editor' of undefined.

Guard against missing entries:

-        const editor = properties[key].editor;
+        if (!properties[key]) {
+          continue;        // or throw a descriptive error
+        }
+        const editor = properties[key].editor;

Failing fast (with a clear message) or skipping unknown keys will make the action more robust.

🧹 Nitpick comments (2)
components/apify/actions/run-actor/run-actor.mjs (2)

152-157: Avoid “undefined Default” in generated descriptions

When a property in the actor schema has no description, you later append the default value:

props[key].description += ` Default: \`${JSON.stringify(value.default)}\``;

If value.description is undefined, the UI will render "undefined Default: …".

Safeguard the concatenation:

-            props[key].description += ` Default: \`${JSON.stringify(value.default)}\``;
+            const baseDesc = props[key].description ?? "";
+            props[key].description = `${baseDesc}${baseDesc ? " " : ""}Default: \`${JSON.stringify(value.default)}\``;

This keeps the UX clean when the original description is missing.


206-224: Consider filtering out undefined params before sending the request

All optional parameters are forwarded even when undefined. Some HTTP clients omit such keys, but relying on that can be brittle:

params: {
  outputRecordKey,
  timeout,
  ...
}

A quick utility to strip undefined (or null) keeps the payload minimal and avoids accidental API validation errors when Apify introduces stricter schemas:

-      params: {
-        outputRecordKey,
-        timeout,
-        ...
-      },
+      params: Object.fromEntries(
+        Object.entries({
+          outputRecordKey,
+          timeout,
+          memory,
+          maxItems,
+          maxTotalChargeUsd,
+          waitForFinish,
+          webhooks,
+        }).filter(([, v]) => v !== undefined),
+      ),
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9ae9d77 and 9b61d71.

📒 Files selected for processing (2)
  • components/apify/actions/run-actor/run-actor.mjs (5 hunks)
  • components/apify/apify.app.mjs (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/apify/apify.app.mjs
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Publish TypeScript components
  • GitHub Check: pnpm publish
  • GitHub Check: Verify TypeScript components
🔇 Additional comments (1)
components/apify/actions/run-actor/run-actor.mjs (1)

3-3: Confirm availability of parseObject helper

A new import was added:

import { parseObject } from "../../common/utils.mjs";

Please verify that:

  1. parseObject exists and is exported from the referenced path.
  2. It is tree‑shakeable and does not pull heavy dependencies into every Apify action.

If the helper is trivial (e.g., JSON.parse wrapper), consider inlining it to avoid an extra import.

@michelle0927
Copy link
Collaborator Author

/approve

@michelle0927
Copy link
Collaborator Author

/approve

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.

[ACTION] Improve Apify actions
2 participants