hatchet-dev / hatchet-python

Hatchet Python SDK for Interacting with the Hatchet Engine
10 stars 4 forks source link

bug: client.admin.run_workflow raises KeyError #10

Closed trisongz closed 2 months ago

trisongz commented 2 months ago

SDK Version: 0.23.0

The latest raises an error due to the following:

class AdminClientImpl:
   ...
   def run_workflow(
        self,
        workflow_name: str,
        input: any,
        options: TriggerWorkflowOptions = None,
    ):
        """
        Handle the run workflow method
        """
        try:
            payload_data = json_serializer.dumps(input)

            try:
                meta = None if options is None else options["additional_metadata"]  # < raises KeyError Here
                # meta = None if options is None else options.get("additional_metadata") 

This was triggered by context.spawn_workflow

class Context:
   ...
    def spawn_workflow(self, workflow_name: str, input: dict = None, key: str = None):
        """
        Spawns a workflow
        """
        input = input or {}
        workflow_run_id = self.action.workflow_run_id
        step_run_id = self.action.step_run_id

        # Since `additional_metadata` doesn't exist here
        options: ScheduleTriggerWorkflowOptions = {
            "parent_id": workflow_run_id,
            "parent_step_run_id": step_run_id,
            "child_key": key,
            "child_index": self.spawn_index,
        }

        self.spawn_index += 1
        child_workflow_run_id = self.client.admin.run_workflow(
            workflow_name, input, options
        )
grutt commented 2 months ago

Sorry about that @trisongz, we'll have a fix published shortly in 0.23.1 (#11)