Skip to content

feat: return input schema on start() invalid-input errors - #1275

Open
MQ37 wants to merge 7 commits into
masterfrom
feat/call-actor-input-error-schema
Open

feat: return input schema on start() invalid-input errors#1275
MQ37 wants to merge 7 commits into
masterfrom
feat/call-actor-input-error-schema

Conversation

@MQ37

@MQ37 MQ37 commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

What

When actor.start() is rejected by the platform with a confirmed invalid-input 400 (real-schema validation, not our own AJV copy), call-actor/call-actor-widget and direct per-Actor tools now return the Actor's input schema and the platform's own message instead of falling through to the generic "verify the Actor name, input parameters, and ensure the Actor exists" text. No extra network call — the schema was already fetched during resolveAndValidateActor (or already known at tools/list time for direct actor tools).

Why

Split out from #1256 per review: a remote pre-flight validate-input call can't reduce failures (same validator either way), but the existing fallback message on a real start()-time input rejection points the agent at the wrong problem. This fixes just that response shape.

Direct actor tools (actor_executor.ts) hit the same platform rejection via their own actor.start() call but had no interception at all — extended after the initial call-actor fix landed. Kept as independent inline logic in each of the two call sites rather than a shared helper: measured a shared module at +17 net lines to guard a duplication that's structurally capped at exactly these two places (the only two spots in this codebase that start() an Actor against user-supplied input).

Testing

pnpm run type-check/lint/test:unit/format/check:agents clean (93 files, 1361 passed, 1 skipped, zero regressions). Unit tests cover: schema+message returned (not the generic fallback) when inputSchema is available, the platform message alone when it isn't, the direct-actor-tool executor delegating instead of throwing, any other start() error rethrown unchanged, and the isActorInputValidationError predicate matching only the confirmed error type (not the sibling invalid-input-schema).

@github-actions github-actions Bot added t-ai Issues owned by the AI team. tested Temporary label used only programatically for some analytics. labels Aug 18, 2026
@MQ37
MQ37 marked this pull request as draft August 18, 2026 15:11
MQ37 added 4 commits August 19, 2026 09:22
call-actor/call-actor-widget fell through to a generic 'verify the
Actor name' message on a platform invalid-input 400 from start() —
pointing the agent at the wrong problem. Branch that path: for a
confirmed platform input-validation error, return the input-specific
message and the Actor's input schema, not the Actor-name/existence
hint. No extra network call — the schema was already fetched during
resolveAndValidateActor.

Discriminator: apify-core throws every start()-body validation
failure (bad JSON, wrong type, real-schema mismatch) as ApifyApiError
type 'invalid-input', status 400 — distinct from 'invalid-input-schema'
(a broken schema on the Actor itself, not a user input problem).

Written with AI assistance (Claude).
…ols too

Direct per-Actor tools (actor_executor.ts) hit the same platform
invalid-input 400 from actor.start() as call-actor, but errors there
fell through to the fully generic tool-call error mapper — no schema,
no input-specific message. Wrap just the start() call and intercept
the confirmed platform-validation case; everything else rethrows
unchanged, unaffected.

Inline, not a shared helper with call_actor.ts: verified LOC — a
shared module costs 17 more net lines and a new file to guard a
duplication that's structurally capped at these two call sites (the
only two places in this codebase that start() an Actor against
user-supplied input).
Same AJV-vs-platform-schema explanation was written out at 3 call sites; kept it at its one canonical home (isActorInputValidationError's JSDoc), call sites now just point at it.
@MQ37
MQ37 force-pushed the feat/call-actor-input-error-schema branch from 05c7b1b to 87865c6 Compare August 19, 2026 07:26
MQ37 added 3 commits August 19, 2026 11:01
expect(spies.startInput).toBeUndefined() checked a variable the test's own apifyClient override never wires up — always undefined regardless of code behavior.
Same respondUserError message array was duplicated in actor_executor.ts
and call_actor.ts for the isActorInputValidationError branch. Single-source
it next to isActorInputValidationError, mirroring the existing
buildPermissionApprovalTexts/buildActorNotFoundHint pattern.
@MQ37
MQ37 marked this pull request as ready for review August 20, 2026 09:14
@MQ37
MQ37 requested a review from jirispilka August 20, 2026 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-ai Issues owned by the AI team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants