chore: unify argument validation to zod - #3935
Draft
vladfrangu wants to merge 6 commits into
Draft
Conversation
vladfrangu
force-pushed
the
chore/unify-to-zod
branch
2 times, most recently
from
July 30, 2026 13:10
48101f6 to
acb4aab
Compare
…gument results Message format matches #3716: the zod issue message plus the offending field path and the received value. parseArgument drops the label argument and returns the parsed (default-applied) value, typed as the input intersected with the schema output.
…nce validators Options are now destructured from the parse result with defaults declared in the schemas, all per-call schemas are hoisted to module scope, and instance-like options are validated with specific validators (instanceof for classes, objectWithKeys for interfaces) instead of anyObject.
Crawler and launcher classes build their strict options schema once as a static (optionsSchema) and consume the parse result. Adds missing optionsShape entries (requestManager, ignoreIframes, ignoreShadowRoots) and makes LazyDefaultHttpClient extend BaseHttpClient so it passes the new instanceof validation.
Consumers were mixing the class from @crawlee/http-client with the same-named interface from @crawlee/types, producing aliased duplicate imports (BaseHttpClient_2) in the public API reports. Since httpClient options are now validated with instanceof, the class is the actual contract — import it everywhere. Only the definition site keeps the interface (the class implements it).
vladfrangu
force-pushed
the
chore/unify-to-zod
branch
from
August 4, 2026 14:16
035764d to
e9dee4f
Compare
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.
Replaces the remaining
ow-based argument validation withzodacross all packages and reworks how validation results are consumed.Closes #3716
What changed
owis gone — every argument check now goes throughparseArgument(value, schema)from@crawlee/utils, backed by shared zod schemas.ArgumentValidationErrorrenders the zod issue message plus the offending field path and the received value (e.g.Invalid input: expected number at `maxConcurrency`, got `NaN`). The rawZodErroris exposed as a typedcause, and itsissuesdirectly on the error..default(...)), and call sites destructure the typed parse result.parseArgumentreturnsTValue & z.output<TSchema>, so call sites keep their declared TS types while gaining the defaults.static optionsSchemanext tooptionsShape.anyObject— class-typed options usez.instanceof(...)(BaseHttpClient,Configuration,EventManager,Snapshotter,KeyValueStore), interface-typed ones use duck-typedobjectWithKeysvalidators (storageBackend,requestManager,logger).Notes
BaseHttpClientfrom@crawlee/http-clientrather than just implementing the interface (all shipped clients already do;LazyDefaultHttpClientwas converted).z.custom-based) to keep their prototypes — there are comments at the relevant schemas.optionsShapegaps that the strict schemas surfaced:requestManageronBasicCrawler,ignoreIframes/ignoreShadowRootsonBrowserCrawler.