You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit was created on GitHub.com and signed with GitHub’s verified signature.
@pipelex/sdk on npm
Added
A verdict on every error: retryable, errorDomain and errorVerdictOf: every error class the package exports now carries retryable, whether asking again can succeed, and errorDomain, who can fix the failure (input, config or runtime), both always decided, and errorVerdictOf(err) reads the pair from anything a catch holds, returning undefined for an error that is not the SDK's, such as an argument of the wrong type or range, or the caller's own abort. The classes now derive from the new abstract PipelexRequestError, itself a PipelineRequestError; ErrorDomain and ErrorVerdict are exported, InputPreparationError and ArtifactOperationError take an optional verdict in their options for a subclass of your own, RunFailedError takes its verdict from the run's report, and CodegenLockError carries the two members too. docs/errors.md lists each class's verdict.
RequestArgumentError: the error the client throws when it refuses a call's arguments before sending any request, a PipelexRequestError whose verdict is input and not retryable unless its options declare another, as the client does with config for a base URL that is not host-only.
Changed
ApiResponseError.retryable and ApiResponseError.errorDomain are always decided (Breaking): retryable is now boolean and errorDomain is ErrorDomain instead of boolean | undefined and string | undefined. Each is the problem document's member when the server sent a valid one, and otherwise the SDK's fallback, read from the status, the platform code and whether the body names what it refused; a domain outside the three reads as absent, and when the server sent a valid domain but no retryable, an input or config domain is not retryable, as a failed run's report that says nothing is not, while a runtime one takes the fallback's. Code that tested either for undefined to learn what the server sent now reads problemDocument.
iterateMethods throws PagingNotTerminatingError (Breaking): a server that keeps minting fresh cursors past the page ceiling now ends the iteration with the new PagingNotTerminatingError, carrying pageLimit and named as in the Python SDK, instead of a plain Error.
Argument refusals throw RequestArgumentError: no run source given to execute() or start(), run sources or method selectors that exclude each other, the selector rules of validate(), an empty validateFiles(), a reserved key in extra and a base URL that is not host-only threw a bare PipelineRequestError with no verdict, and now throw RequestArgumentError, still a PipelineRequestError; a refusal from the standard's own run-source check keeps the original error as cause.
health() throws the typed errors (Breaking): the liveness probe now goes through the client's own transport, so an unreachable origin is an ApiUnreachableError instead of the runtime's raw TypeError, a non-2xx answer is an ApiResponseError naming /health instead of a plain Error, and the probe gives up after the 30-second management timeout.
Fixed
A failed run's stored report is checked field by field: the report on getRunResult's failed arm, on RunFailedError, on getRunStatus, on each row of listRuns and iterateRuns and on getRunDetail was handed back as cast; each named field is now kept only when it has its declared type and reads as absent otherwise, user_action only whole, and members the SDK does not name are relayed as sent.
A wrapped upload refusal carries its cause's verdict: an UploadTransportError from uploadFile takes the verdict of the ApiResponseError or ApiUnreachableError it wraps, so a 402 plan refusal, whose transport code is unexpected, reads as config and not retryable rather than as a transient fault.
Storage's 501, 408 and 429 from uploadWithGrant give the right retry advice: storage's 501, its answer to a request it does not implement, threw an UploadTransportError with code server_error whose message advised retrying with the same grant; the message now says storage stored nothing and a retry meets the same answer, and the error is runtime and not retryable, while any other 5xx stays retryable. A 408 or a 429, storage timing out or throttling the request, threw a RejectedAssetError with code store_refused that asked for a new grant or another file; it now throws an UploadTransportError with code unexpected and storage's status, runtime and retryable, whose message says a later attempt can succeed with the same grant.
ApiResponseError's nested members are checked: providerMetadata, migration, validationErrors and each item of errors were cast from the problem document once they were an object or an array; each is now checked field by field as a failed run's stored report is, so a misfit field reads as absent and a validation item without a string category and message is dropped.
An unreadable 2xx answer throws an ApiResponseError: a 2xx whose body is not JSON, on any route and on health(), let the runtime's bare SyntaxError escape with no verdict; a body that is JSON but not the object the route answers (null, a number, an array) let a TypeError escape from getRunResult, listMethods, getMethod and the other routes whose answer the SDK reads, and came back as the value of getRunDetail and requestUploadGrant, an empty body too; a page of listMethods or listRuns whose items is not an array made iterateMethods and iterateRuns throw a bare TypeError, and one with no next_cursor made iterateRuns loop forever and iterateMethods repeat its first page until it gave up; an upload answer with no string uri became an upload record with no URI, which prepareInputs handed back as a file input with no URL; a stored method whose mthds field is not a string made getMethodClosure throw a bare TypeError; and one whose python field is not the serialized file list made getMethod, createMethod and updateMethod throw mthds's bare PipelineRequestError. Each now throws an ApiResponseError carrying the status and the raw text, runtime and not retryable, which uploadFile wraps as an UploadTransportError with code unexpected, and uploadFile keeps the filename it sent when the answer names none. prepareInputs threw a bare TypeError on an invalid pipe I/O answer without a validation_errors list, and now reports the answer's own message, while an answer whose is_valid is not a boolean is an InputPreparationError that is runtime and not retryable.
Removed
ClientAuthenticationError (Breaking): the class is no longer exported. Nothing in the SDK ever threw it, so delete any instanceof ClientAuthenticationError arm.