Skip to content

refactor(extras): drop redundant MicroVM checks - #834

Merged
ParidelPooya merged 5 commits into
mainfrom
refactor/microvm-input-checks
Oct 25, 2026
Merged

ParidelPooya merged 5 commits into
mainfrom
refactor/microvm-input-checks

Conversation

@ParidelPooya

@ParidelPooya ParidelPooya commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

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

  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 checks answer no to all three.
  3. So they are removed, and the best-practices docs state the rule instead.

This is item D7 of that review. The JS SDK removes the matching checks in aws/aws-durable-execution-sdk-js#1089.

Changes

Extras:

  • The guard in the request step for an HTTP launch recorded without an endpoint is removed. _launch_call already refuses that launch, and the launch step checkpoints only what _launch_call returned.
  • The empty checks for image_identifier and execution_role_arn are removed. botocore rejects both with ParamValidationError from the API model's minimum lengths, so the operation fails with MicrovmLaunchError.
  • The check of the first argument of vm.invoke, and the check that the session handler is callable, are removed. The outer-context check stays, because it prevents a replay break.
    • A call without the context, vm.invoke("build", job_input=..., options=...), raises Python's TypeError. A first argument that is not a durable context raises AttributeError.
    • A handler that is not callable raises TypeError inside the child context, after the launch. The session terminates the MicroVM.
  • add_request_id drops its str(labelled) != message guard. The outcome was the same without it.
  • request_id_sentence reads the request ID with one .get chain.

Worker:

  • The runtime branch for a handler that returns an awaitable is removed. The create-time rejection of an async def handler stays. A returned coroutine now fails the job with ResultSerializationError.

Kept, so that Python behaves as JS: the bool port rejection and loads_strict. An earlier commit of this PR removed them, and 106db1e and 05b2db9 restore them.

Testing

  • New tests pin each new failure. The empty image and role test uses a real client wrapped in Stubber.
  • hatch run dev-extras:cov: 375 tests, 100 %. hatch run dev-microvm-worker:cov: 455 tests, worker.py and payload.py 100 %. Typecheck and hatch fmt --check pass.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

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.

@yaythomas yaythomas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@ParidelPooya
ParidelPooya marked this pull request as ready for review October 25, 2026 01:06
@ParidelPooya
ParidelPooya merged commit 38c1333 into main Oct 25, 2026
21 checks passed
@ParidelPooya
ParidelPooya deployed to ai-pr-review-runtime October 25, 2026 01:06 — with GitHub Actions Active
@ParidelPooya
ParidelPooya deleted the refactor/microvm-input-checks branch 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

1 active deployment
ai-pr-review-runtime — 07a1cc32 Deployed Oct 25, 2026 by ParidelPooya via notify / Generate notification summary #288
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants