feat: add validateInput method to ActorClient#957
Conversation
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
|
See more at https://github.com/apify/apify-client-js/actions/runs/28576274270#summary-84725516603 |
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
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RHew3HnUL5edKJ6DqYr1Be
There was a problem hiding this comment.
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 byPOST /v2/actors/{actorId}/validate-input. - Adds mock-server routing for the new endpoint.
- Adds unit tests for basic validation,
buildquery param handling, customcontentTypebehavior (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.
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
validateInput method to ActorClient
77682bd to
6d09491
Compare
There was a problem hiding this comment.
See that with any non-application/json content-type header, the server will return an API error (see source):
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).
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.
Description
validateInputmethod toActorClientIssues
Closes: #425