Skip to content

Conversation

@Aaron1011
Copy link
Member

The 'spawn_by_name' method requires the task to exist in the registry, so we can validate the parameters by attempting to deserialize into the parameter type.

This lets us catch some errors before we try to insert the task into the database

The 'spawn_by_name' method requires the task to exist
in the registry, so we can validate the parameters by attempting
to deserialize into the parameter type.

This lets us catch some errors before we try to insert the task
into the database
@cursor
Copy link

cursor bot commented Jan 14, 2026

PR Summary

Adds pre-spawn parameter validation for dynamic spawns and surfaces clear errors.

  • Validate params in spawn_by_name_with by looking up the task in the registry and calling task.validate_params(...); spawn_by_name now routes through this path
  • Introduce DurableError::InvalidTaskParams for early, descriptive failures on bad JSON
  • Extend internal ErasedTask with validate_params; default impl deserializes into T::Params
  • Add test test_spawn_by_name_invalid_params and update complex-params test to use spawn_by_name_unchecked (no validation)

Written by Cursor Bugbot for commit b6cec91. This will update automatically on new commits. Configure here.

// Validate that the task is registered
{
let registry = self.registry.read().await;
if !registry.contains_key(task_name) {
Copy link

Choose a reason for hiding this comment

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

New validation breaks tests expecting arbitrary JSON parameters

High Severity

The new parameter validation in spawn_by_name_with breaks existing tests that rely on spawn_by_name accepting arbitrary JSON. Two tests (test_spawn_with_empty_params and test_spawn_with_complex_params) explicitly document this behavior with comments stating params "don't need to match the task's Params type because spawn_by_name accepts arbitrary JSON." These tests pass invalid EchoParams (missing required message field or wrong structure) and will now fail validation.

Fix in Cursor Fix in Web

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