feat: add apify actors doctor for local Actor diagnostics - #1367
Open
kuntal1461 wants to merge 1 commit into
Open
feat: add apify actors doctor for local Actor diagnostics#1367kuntal1461 wants to merge 1 commit into
apify actors doctor for local Actor diagnostics#1367kuntal1461 wants to merge 1 commit into
Conversation
Adds apify actors doctor — an offline, read-only pre-flight command that checks the local Actor project before deployment. Reuses canonical Apify validators from @apify/json_schemas and @apify/input_schema. Checks: actor.json presence, JSON parsing, canonical Actor schema, Actor name constraints, and all referenced schema files (input, output, dataset, KVS), including both singular and plural/alias forms. Also improves shared schema resolution in src/lib/input_schema.ts and src/commands/validate-schema.ts to recognise inputSchema/outputSchema aliases and storages.datasets plural form consistently across commands. Closes apify#1366
kuntal1461
requested review from
DaveHanns,
l2ysho and
szaganek
as code owners
August 29, 2026 21:24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1366
Summary
Adds
apify actors doctor— an offline, read-only diagnostic command that checks the local Actor project before deployment. The intended workflow is:Doctor catches locally representable configuration and schema problems (malformed config, missing schema references, invalid schema structure) before a push is attempted. Passing doctor does not guarantee a successful cloud build — it validates only what is locally checkable.
Why this helps developers
Architecture
Doctor owns orchestration and presentation; canonical Apify validators own the rules. This avoids a second ruleset that could drift from the Actor specification.
Why this architecture
The central design constraint is that doctor must not duplicate validation rules. Every check delegates to an existing canonical validator:
getActorSchemaValidator()(@apify/json_schemas) — actor.json structurevalidateInputSchema()(@apify/input_schema) — input schema validitygetDatasetSchemaValidator(),getOutputSchemaValidator(),getKeyValueStoreSchemaValidator()(@apify/json_schemas) — storage schema validityDoctor's own code handles: discovery, parsing, short-circuit logic (don't crash on
nullactor.json), error aggregation, and terminal rendering.Trade-offs
Separate command instead of changing
actors pushOffline instead of cloud simulation
Canonical checks only, no heuristics
package.json, lock files, Node version, Python environment, or DockerShared helper changes instead of doctor-only parsing
input_schema.tsandvalidate-schema.tsbenefit all consumersSimple flat check list instead of a plugin/registry framework
Impact on existing commands
apify actors pushapify validate-schemainputSchema/outputSchemaaliases andstorages.datasetsplural formapify actor generate-schema-typesstorages.datasetstype generation remains out of scopeapify initapify runShared improvements
src/lib/input_schema.tsnow consistently handles:inputSchemaas an alias forinput(canonical actor schema supports both)outputSchemaas an alias foroutputstorages.datasets(plural, named entries) alongsidestorages.dataset(singular)ref-missingvsparse-failedare reported as distinct diagnosticsThese forms are part of the canonical Actor schema; the previous shared reader code did not handle them consistently.
validate-schemanow uses these improved readers, so it benefits from the same correctness fix.Safety characteristics
actor.jsonactor.jsonroot values (null,[], strings, numbers, booleans) produce a clean canonical schema error and do not crashTesting
Automated tests
actors doctorvalidate-schemaactor generate-schema-typesapify pushapify initpnpm run lintpnpm exec tsc --noEmitpnpm run formatReal CLI testing
The built local entrypoint (
dist/apify.js actors doctor) was exercised against real temporary Actor projects covering:.actor/actor.json→ clean error diagnosticactor.json(invalid JSON) → parse error diagnosticnull/[]/ string / number / booleanactor.json→ canonical schema error, no crashinputandinputSchemafield formsoutputandoutputSchemafield formsstorages.datasetandstorages.datasetswith multiple named entriesstorages.keyValueStoreapify.jsonwith and withoutactor.jsonpresentBackward compatibility
actors pushbehavior is unchangedactors doctoris strictly additiveKnown limitations / follow-ups
The following are pre-existing concerns intentionally excluded from this PR to keep it focused:
actor generate-schema-typesdoes not yet generate types fromstorages.datasetsentries (plural form) — separate concernACTOR_NAME.MAX_LENGTHis 63 — pre-existing message inconsistencyruntest suite could not complete locally due to unrelated environment/setup prerequisites (TEST_USER_TOKEN, template network fetch); isolated from this feature