Skip to content

feat: add validateInput method to ActorClient#957

Merged
Pijukatel merged 7 commits into
masterfrom
claude/actor-validate-input-js-mzm4ur
Jul 3, 2026
Merged

feat: add validateInput method to ActorClient#957
Pijukatel merged 7 commits into
masterfrom
claude/actor-validate-input-js-mzm4ur

Conversation

@Pijukatel

@Pijukatel Pijukatel commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Description

Issues

Closes: #425

Add ActorClient.validateInput(input, { build, contentType }) backed by
POST /v2/actors/{actorId}/validate-input, reaching parity with the Python
client. Resolves to true when the input passes the Actor's input schema;
invalid input is surfaced as a thrown ApifyApiError.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RHew3HnUL5edKJ6DqYr1Be
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

⚠️ There are broken links in the documentation.

See more at https://github.com/apify/apify-client-js/actions/runs/28576274270#summary-84725516603

claude and others added 4 commits July 2, 2026 07:19
Mirrors the start() function-input test to assert that function properties
in the input survive serialization (stringifyFunctions), so validateInput
sends the same payload start() would.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RHew3HnUL5edKJ6DqYr1Be
…ateInput

Drop the custom content-type validateInput test and add one asserting that
validateInput rejects (throws ApifyApiError) when the API responds with an
error status, covering the invalid-input failure path.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RHew3HnUL5edKJ6DqYr1Be

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds an ActorClient.validateInput() API to the JS client so callers can validate an Actor input against the Actor’s input schema without starting a run, matching the Python client’s behavior.

Changes:

  • Introduces ActorClient.validateInput(input?, { build?, contentType? }) backed by POST /v2/actors/{actorId}/validate-input.
  • Adds mock-server routing for the new endpoint.
  • Adds unit tests for basic validation, build query param handling, custom contentType behavior (incl. function serialization), and error propagation.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/resource_clients/actor.ts Adds the validateInput() method and its options interface.
test/mock_server/routes/actors.ts Registers the mock route for /:actorId/validate-input.
test/actors.test.ts Adds unit tests covering success, options, function serialization, and error cases.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/resource_clients/actor.ts Outdated
Use the ApifyRequestConfig type (which models stringifyFunctions) instead of
AxiosRequestConfig, dropping the @ts-expect-error suppression and stale TODO.
Matches the pattern already used by task/dataset/key-value-store clients.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RHew3HnUL5edKJ6DqYr1Be
@Pijukatel Pijukatel changed the title feat: add validateInput method to ActorClient feat: add validateInput method to ActorClient Jul 2, 2026
@Pijukatel Pijukatel force-pushed the claude/actor-validate-input-js-mzm4ur branch from 77682bd to 6d09491 Compare July 2, 2026 08:27
@Pijukatel Pijukatel requested a review from barjin July 2, 2026 08:29

@barjin barjin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See that with any non-application/json content-type header, the server will return an API error (see source):

Image

Also note that passing explicit { contentType: "application/json" } with a Buffer will JSON-serialize the Buffer representation (this is a preexisting issue we imo don't need to solve here).

Image

Approving since this works the same as the other existing methods (Actor.start(), Task.start() etc.). We might want to look into these gaps later on, though.

@Pijukatel Pijukatel merged commit 3637586 into master Jul 3, 2026
7 checks passed
@Pijukatel Pijukatel deleted the claude/actor-validate-input-js-mzm4ur branch July 3, 2026 09:33
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.

Add API endpoint for validating Actor input

5 participants