Repository navigation
refactor(extras): drop redundant MicroVM checks - #834
Merged
Merged
Conversation
Remove the empty image and role checks, the bool port check, the invoke context and handler callable checks, the unreachable endpoint guard, and the str() guard in add_request_id. Each removed case cannot occur, or it still fails visibly at the launch or at the call. Read the request ID with one get chain.
Remove loads_strict, because is_finite_number already rejects NaN and Infinity in every number field that the worker reads. Remove the branch in _Outcome.of for a returned awaitable. A returned coroutine now fails the job with ResultSerializationError.
Restore the check that rejects a bool request port. The check keeps Python's behavior the same as JavaScript, which rejects true.
Restore loads_strict, which rejects NaN and Infinity anywhere in the body. The check keeps Python's behavior the same as the JS worker.
This addresses the round 1 review of the input check removal. A call without the context raises TypeError, and a test now checks it.
ParidelPooya
marked this pull request as ready for review
October 25, 2026 01:06
ParidelPooya
added a commit
to aws/aws-durable-execution-sdk-js
that referenced
this pull request
Oct 25, 2026
## Summary This PR removes three checks of developer input in the MicroVM operations. Without each check, the same mistake still fails visibly. A test pins each new failure. ## Why 1. A review of the MicroVM safeguards sorted each check by three questions. Is the failure silent without it? Can the developer control the cause? Does the failure leak cost or break replay? 2. These three checks answer no to all three. Each one only moves a visible error earlier. 3. So they are removed, and the best-practices docs state the rule instead. This is item D7 of that review. The Python SDK removes the matching checks in aws/aws-durable-execution-sdk-python#834. ## Changes - `remainingTime()` keeps the `typeof read === "function"` check. It drops the try/catch and the finiteness check. `reserveStartsAt` and `assertTimeToDeliver` already treat a value that is not finite as no deadline. A reader that throws now fails the request step with its own error, as in the Python extras. The core SDK reads such a reader as no deadline, and the README says the MicroVM operations differ. - `microvmSession` no longer checks that the handler is a function. A value that is not a function fails inside the session's child context with a `TypeError`, after the launch. The terminate step ends the MicroVM. - `vm.invoke` no longer checks that its first argument has `runInChildContext`. A wrong first argument throws a `TypeError` inside the session's child context. TypeScript rejects both mistakes at compile time. - `validateBaseConfig` no longer checks for an empty `imageIdentifier` or `executionRoleArn`. `RunMicrovm` rejects both with `ValidationException`, which is not retried. So the operation fails with `MicrovmLaunchError`. - README "Errors", "Function timeout" and "Sessions and auto-suspend", and the TSDoc, are updated. ## Testing - New tests: a reader that throws fails the delivery; a handler that is not a function, and an `invoke` without a durable context, each fail after one launch and one terminate; an empty image or role reaches `RunMicrovm` and fails with `MicrovmLaunchError`. - Extras `npm test`: 330 tests pass. `npm run lint` and `npm run format:check` pass. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
This branch was successfully deployed
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.
Summary
This PR removes six checks in the MicroVM extras and worker. Each check either cannot run, repeats another check, or only moves a visible error earlier. A test pins each new failure.
Why
This is item D7 of that review. The JS SDK removes the matching checks in aws/aws-durable-execution-sdk-js#1089.
Changes
Extras:
_launch_callalready refuses that launch, and the launch step checkpoints only what_launch_callreturned.image_identifierandexecution_role_arnare removed. botocore rejects both withParamValidationErrorfrom the API model's minimum lengths, so the operation fails withMicrovmLaunchError.vm.invoke, and the check that the session handler is callable, are removed. The outer-context check stays, because it prevents a replay break.vm.invoke("build", job_input=..., options=...), raises Python'sTypeError. A first argument that is not a durable context raisesAttributeError.TypeErrorinside the child context, after the launch. The session terminates the MicroVM.add_request_iddrops itsstr(labelled) != messageguard. The outcome was the same without it.request_id_sentencereads the request ID with one.getchain.Worker:
async defhandler stays. A returned coroutine now fails the job withResultSerializationError.Kept, so that Python behaves as JS: the
boolport rejection andloads_strict. An earlier commit of this PR removed them, and 106db1e and 05b2db9 restore them.Testing
Stubber.hatch run dev-extras:cov: 375 tests, 100 %.hatch run dev-microvm-worker:cov: 455 tests,worker.pyandpayload.py100 %. Typecheck andhatch fmt --checkpass.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.