fix: Required fields dropped from tools/list for all Actors#676
Conversation
filterSchemaProperties() writes phantom `default: undefined` on every property. The previous key-presence check (`'default' in field`) matched these phantoms and cleared the required array for every Actor. Switch to a value-check (`field.default !== undefined`) — same pattern used by the Apify platform validator. Adds unit tests for fixZodSchemaRequired and an end-to-end pipeline test modelled on apify/rag-web-browser. Adds a TODO(#675) on filterSchemaProperties for the follow-up cleanup at the source. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
LGTM — targeted one-line fix with solid regression coverage.
Extended reasoning...
Overview
Patches a bug in fixZodSchemaRequired() (src/utils/ajv.ts) where a key-presence check ('default' in fieldSchema) was incorrectly treating phantom default: undefined entries — produced by filterSchemaProperties() — as real defaults, stripping every Actor's required fields in tools/list.
Fix
Single-line change: replace the key-presence check with a value-check (fieldSchema.default === undefined). This matches the pattern used by Apify's platform-side input-schema validator and correctly ignores undefined-valued phantom keys.
Security risks
None. The change only affects JSON schema normalization for MCP tool listings; no auth, crypto, or permission logic is touched.
Level of scrutiny
Low. The root cause is clearly explained, the fix is minimal and isolated, and the follow-up phantom-key cleanup is deferred to #675 with a TODO comment. New tests in utils.ajv.test.ts, tools.mode_contract.test.ts, and tools.utils.test.ts directly exercise the regression cases.
Other factors
Non-code changes (docs, .gitignore) are trivial. No outstanding reviewer comments. PR is labeled tested.
Fixes #637.
Root cause
filterSchemaProperties()unconditionally assignsdefault: property.defaulton every whitelisted property, creating a phantomdefault: undefinedkey on properties with no upstream default. The previous key-presence check ('default' in field) matched these phantoms and cleared therequiredarray for every Actor intools/list— soquery,startUrls,queries, etc. all appeared optional.Fix
Switch to a value-check (
field.default !== undefined) infixZodSchemaRequired()— same pattern used by the Apify platform-side input-schema validator.Verified
Tested with mcpc on
@stdio-fullagainstapify/rag-web-browser,apify/google-search-scraper,apify/web-scraper,apify/instagram-scraper, and others — all required fields now correctly populated.Follow-up
The phantom-key corruption itself (in
filterSchemaProperties) is tracked in #675.