sdk-php icon indicating copy to clipboard operation
sdk-php copied to clipboard

[Bug] Abstract Workflow not started

Open root-aza opened this issue 1 year ago • 0 comments

What are you really trying to do?

We are trying to start a workflow with a class descendant

Describe the bug

Minimal Reproduction

Code
<?php

declare(strict_types=1);

namespace App\LoanApplication\Workflow;

use Generator;
use Temporal\Workflow;
use Temporal\Workflow\WorkflowMethod;

abstract class AbstractWorkflow
{
    #[WorkflowMethod]
    final public function start(string $id): Generator
    {
        $workflow = Workflow::newExternalWorkflowStub(
            RootWorkflow::class,
            new Workflow\WorkflowExecution($id)
        );


        yield from $this->go($workflow);
    }


    /**
     * @param RootWorkflow $workflow
     */
    abstract protected function go($workflow): Generator;
}
<?php

declare(strict_types=1);

namespace App\LoanApplication\Workflow;

use Generator;
use Temporal\Workflow\WorkflowInterface;
use Vanta\Integration\Symfony\Temporal\Attribute\AssignWorker;

#[WorkflowInterface]
#[AssignWorker('bus.bank_application')]
final class AWorkflow extends AbstractWorkflow
{
    protected function go($workflow): Generator
    {
        yield $workflow->ok();
    }
}
<?php

declare(strict_types=1);

namespace App\LoanApplication\Workflow;

use Generator;
use Temporal\Workflow;
use Temporal\Workflow\ChildWorkflowOptions;
use Temporal\Workflow\ParentClosePolicy;
use Temporal\Workflow\SignalMethod;
use Temporal\Workflow\WorkflowInterface;
use Temporal\Workflow\WorkflowMethod;
use Vanta\Integration\Symfony\Temporal\Attribute\AssignWorker;

#[WorkflowInterface]
#[AssignWorker('bus.bank_application')]
final class RootWorkflow
{
    private bool $status = false;


    #[WorkflowMethod]
    public function start(): Generator
    {
        $workflow = Workflow::newChildWorkflowStub(
            AWorkflow::class,
            ChildWorkflowOptions::new()
                ->withNamespace(Workflow::getInfo()->namespace)
                ->withTaskQueue('bus.bank_application')
                ->withParentClosePolicy(ParentClosePolicy::POLICY_ABANDON)
        );


        $workflow->start(Workflow::getInfo()->execution->getID());


        yield Workflow::await(fn(): bool => $this->status);
    }


    #[SignalMethod]
    public function ok(): null
    {
        $this->status = true;

        return null;
    }
}
StackTrace

{
  "message": "The given stub class \"App\\LoanApplication\\Workflow\\AWorkflow\" does not contain a workflow method named \"start\"",
  "source": "PHP_SDK",
  "stackTrace": "#0  /var/www/api/src/LoanApplication/Workflow/RootWorkflow.php:41\n    Temporal\\Internal\\Workflow\\ChildWorkflowProxy->__call(\"start\",array(1))\n#1  /var/www/api/vendor/temporal/sdk/src/Internal/Workflow/Process/Scope.php:363\n    App\\LoanApplication\\Workflow\\RootWorkflow->start()\n#2  [internal function]\n    Temporal\\Internal\\Workflow\\Process\\Scope->call(Closure,Temporal\\DataConverter\\EncodedValues)\n#3  /var/www/api/vendor/temporal/sdk/src/Internal/Workflow/Process/Scope.php:452\n    Generator->valid()\n#4  /var/www/api/vendor/temporal/sdk/src/Internal/Workflow/Process/Scope.php:186\n    Temporal\\Internal\\Workflow\\Process\\Scope->next()\n#5  /var/www/api/vendor/temporal/sdk/src/Internal/Workflow/Process/Process.php:183\n    Temporal\\Internal\\Workflow\\Process\\Scope->start(Closure,Temporal\\DataConverter\\EncodedValues)\n#6  /var/www/api/vendor/temporal/sdk/src/Internal/Transport/Router/StartWorkflow.php:91\n    Temporal\\Internal\\Workflow\\Process\\Process->start(Closure,Temporal\\DataConverter\\EncodedValues)\n#7  /var/www/api/vendor/temporal/sdk/src/Internal/Interceptor/Pipeline.php:95\n    Temporal\\Internal\\Transport\\Router\\StartWorkflow->Temporal\\Internal\\Transport\\Router\\{closure}(Temporal\\Interceptor\\WorkflowInbound\\WorkflowInput)\n#8  /var/www/api/vendor/temporal/sdk/src/Internal/Transport/Router/StartWorkflow.php:104\n    Temporal\\Internal\\Interceptor\\Pipeline->__invoke(Temporal\\Interceptor\\WorkflowInbound\\WorkflowInput)\n#9  /var/www/api/vendor/temporal/sdk/src/Internal/Transport/Router.php:82\n    Temporal\\Internal\\Transport\\Router\\StartWorkflow->handle(Temporal\\Worker\\Transport\\Command\\ServerRequest,array(4),React\\Promise\\Deferred)\n#10 /var/www/api/vendor/temporal/sdk/src/Worker/Worker.php:91\n    Temporal\\Internal\\Transport\\Router->dispatch(Temporal\\Worker\\Transport\\Command\\ServerRequest,array(4))\n#11 /var/www/api/vendor/temporal/sdk/src/WorkerFactory.php:422\n    Temporal\\Worker\\Worker->dispatch(Temporal\\Worker\\Transport\\Command\\ServerRequest,array(4))\n#12 /var/www/api/vendor/temporal/sdk/src/Internal/Transport/Server.php:63\n    Temporal\\WorkerFactory->onRequest(Temporal\\Worker\\Transport\\Command\\ServerRequest,array(4))\n#13 /var/www/api/vendor/temporal/sdk/src/WorkerFactory.php:399\n    Temporal\\Internal\\Transport\\Server->dispatch(Temporal\\Worker\\Transport\\Command\\ServerRequest,array(4))\n#14 /var/www/api/vendor/temporal/sdk/src/WorkerFactory.php:269\n    Temporal\\WorkerFactory->dispatch(\"\\n\ufffd\\u0005\\b\\u0001\\u0012\\rStartWorkflow\\u001a\ufffd\\u0005{\\\"info\\\":{\\\"WorkflowExecution...\",array(4))\n#15 /var/www/api/vendor/vanta/temporal-bundle/src/Runtime/Runtime.php:32\n    Temporal\\WorkerFactory->run()\n#16 /var/www/api/vendor/vanta/temporal-bundle/src/Runtime/TemporalRunner.php:25\n    Vanta\\Integration\\Symfony\\Temporal\\Runtime\\Runtime->run()\n#17 /var/www/api/vendor/autoload_runtime.php:29\n    Vanta\\Integration\\Symfony\\Temporal\\Runtime\\TemporalRunner->run()\n#18 /var/www/api/public/index.php:7\n    require_once(\"\\/var\\/www\\/api\\/vendor\\/autoload_runtime.php\")",
  "encodedAttributes": null,
  "cause": null,
  "applicationFailureInfo": {
    "type": "BadMethodCallException",
    "nonRetryable": false,
    "details": null
  }
}
Events Workflow
{
  "events": [
    {
      "eventId": "1",
      "eventTime": "2024-05-17T07:44:33.985056926Z",
      "eventType": "WorkflowExecutionStarted",
      "version": "0",
      "taskId": "1048714",
      "workerMayIgnore": false,
      "workflowExecutionStartedEventAttributes": {
        "workflowType": {
          "name": "RootWorkflow"
        },
        "parentWorkflowNamespace": "",
        "parentWorkflowNamespaceId": "",
        "parentWorkflowExecution": null,
        "parentInitiatedEventId": "0",
        "taskQueue": {
          "name": "bus.bank_application",
          "kind": "Normal",
          "normalName": ""
        },
        "input": null,
        "workflowExecutionTimeout": "0s",
        "workflowRunTimeout": "0s",
        "workflowTaskTimeout": "10s",
        "continuedExecutionRunId": "",
        "initiator": "Unspecified",
        "continuedFailure": null,
        "lastCompletionResult": null,
        "originalExecutionRunId": "a675ae9a-f0af-426b-b48e-83a530ff2bc5",
        "identity": "35@6e8cab123894",
        "firstExecutionRunId": "a675ae9a-f0af-426b-b48e-83a530ff2bc5",
        "retryPolicy": null,
        "attempt": 1,
        "workflowExecutionExpirationTime": null,
        "cronSchedule": "",
        "firstWorkflowTaskBackoff": "0s",
        "memo": null,
        "searchAttributes": null,
        "prevAutoResetPoints": null,
        "header": {
          "fields": {}
        },
        "parentInitiatedEventVersion": "0",
        "workflowId": "346c4917-9559-4043-9cfd-49da7afcbdff",
        "sourceVersionStamp": null
      }
    },
    {
      "eventId": "2",
      "eventTime": "2024-05-17T07:44:33.985092009Z",
      "eventType": "WorkflowTaskScheduled",
      "version": "0",
      "taskId": "1048715",
      "workerMayIgnore": false,
      "workflowTaskScheduledEventAttributes": {
        "taskQueue": {
          "name": "bus.bank_application",
          "kind": "Normal",
          "normalName": ""
        },
        "startToCloseTimeout": "10s",
        "attempt": 1
      }
    },
    {
      "eventId": "3",
      "eventTime": "2024-05-17T07:44:33.991138217Z",
      "eventType": "WorkflowTaskStarted",
      "version": "0",
      "taskId": "1048720",
      "workerMayIgnore": false,
      "workflowTaskStartedEventAttributes": {
        "scheduledEventId": "2",
        "identity": "bus.bank_application:7eaf76d2-14b7-4138-b2ec-5b96cfa7e42d",
        "requestId": "21da69d4-e7fb-4efa-bac0-9f2f228f72ce",
        "suggestContinueAsNew": false,
        "historySizeBytes": "278"
      }
    },
    {
      "eventId": "4",
      "eventTime": "2024-05-17T07:44:34.088138134Z",
      "eventType": "WorkflowTaskCompleted",
      "version": "0",
      "taskId": "1048724",
      "workerMayIgnore": false,
      "workflowTaskCompletedEventAttributes": {
        "scheduledEventId": "2",
        "startedEventId": "3",
        "identity": "bus.bank_application:7eaf76d2-14b7-4138-b2ec-5b96cfa7e42d",
        "binaryChecksum": "",
        "workerVersion": {
          "buildId": "3850375e06e98d90ebe249b19dfded53",
          "bundleId": "",
          "useVersioning": false
        },
        "sdkMetadata": {
          "coreUsedFlags": [],
          "langUsedFlags": [
            3
          ],
          "sdkName": "temporal-go",
          "sdkVersion": "1.26.0"
        },
        "meteringMetadata": {
          "nonfirstLocalActivityExecutionAttempts": 0
        }
      }
    },
    {
      "eventId": "5",
      "eventTime": "2024-05-17T07:44:34.088162967Z",
      "eventType": "WorkflowExecutionFailed",
      "version": "0",
      "taskId": "1048725",
      "workerMayIgnore": false,
      "workflowExecutionFailedEventAttributes": {
        "failure": {
          "message": "The given stub class \"App\\LoanApplication\\Workflow\\AWorkflow\" does not contain a workflow method named \"start\"",
          "source": "PHP_SDK",
          "stackTrace": "#0  /var/www/api/src/LoanApplication/Workflow/RootWorkflow.php:41\n    Temporal\\Internal\\Workflow\\ChildWorkflowProxy->__call(\"start\",array(1))\n#1  /var/www/api/vendor/temporal/sdk/src/Internal/Workflow/Process/Scope.php:363\n    App\\LoanApplication\\Workflow\\RootWorkflow->start()\n#2  [internal function]\n    Temporal\\Internal\\Workflow\\Process\\Scope->call(Closure,Temporal\\DataConverter\\EncodedValues)\n#3  /var/www/api/vendor/temporal/sdk/src/Internal/Workflow/Process/Scope.php:452\n    Generator->valid()\n#4  /var/www/api/vendor/temporal/sdk/src/Internal/Workflow/Process/Scope.php:186\n    Temporal\\Internal\\Workflow\\Process\\Scope->next()\n#5  /var/www/api/vendor/temporal/sdk/src/Internal/Workflow/Process/Process.php:183\n    Temporal\\Internal\\Workflow\\Process\\Scope->start(Closure,Temporal\\DataConverter\\EncodedValues)\n#6  /var/www/api/vendor/temporal/sdk/src/Internal/Transport/Router/StartWorkflow.php:91\n    Temporal\\Internal\\Workflow\\Process\\Process->start(Closure,Temporal\\DataConverter\\EncodedValues)\n#7  /var/www/api/vendor/temporal/sdk/src/Internal/Interceptor/Pipeline.php:95\n    Temporal\\Internal\\Transport\\Router\\StartWorkflow->Temporal\\Internal\\Transport\\Router\\{closure}(Temporal\\Interceptor\\WorkflowInbound\\WorkflowInput)\n#8  /var/www/api/vendor/temporal/sdk/src/Internal/Transport/Router/StartWorkflow.php:104\n    Temporal\\Internal\\Interceptor\\Pipeline->__invoke(Temporal\\Interceptor\\WorkflowInbound\\WorkflowInput)\n#9  /var/www/api/vendor/temporal/sdk/src/Internal/Transport/Router.php:82\n    Temporal\\Internal\\Transport\\Router\\StartWorkflow->handle(Temporal\\Worker\\Transport\\Command\\ServerRequest,array(4),React\\Promise\\Deferred)\n#10 /var/www/api/vendor/temporal/sdk/src/Worker/Worker.php:91\n    Temporal\\Internal\\Transport\\Router->dispatch(Temporal\\Worker\\Transport\\Command\\ServerRequest,array(4))\n#11 /var/www/api/vendor/temporal/sdk/src/WorkerFactory.php:422\n    Temporal\\Worker\\Worker->dispatch(Temporal\\Worker\\Transport\\Command\\ServerRequest,array(4))\n#12 /var/www/api/vendor/temporal/sdk/src/Internal/Transport/Server.php:63\n    Temporal\\WorkerFactory->onRequest(Temporal\\Worker\\Transport\\Command\\ServerRequest,array(4))\n#13 /var/www/api/vendor/temporal/sdk/src/WorkerFactory.php:399\n    Temporal\\Internal\\Transport\\Server->dispatch(Temporal\\Worker\\Transport\\Command\\ServerRequest,array(4))\n#14 /var/www/api/vendor/temporal/sdk/src/WorkerFactory.php:269\n    Temporal\\WorkerFactory->dispatch(\"\\n\ufffd\\u0005\\b\\u0001\\u0012\\rStartWorkflow\\u001a\ufffd\\u0005{\\\"info\\\":{\\\"WorkflowExecution...\",array(4))\n#15 /var/www/api/vendor/vanta/temporal-bundle/src/Runtime/Runtime.php:32\n    Temporal\\WorkerFactory->run()\n#16 /var/www/api/vendor/vanta/temporal-bundle/src/Runtime/TemporalRunner.php:25\n    Vanta\\Integration\\Symfony\\Temporal\\Runtime\\Runtime->run()\n#17 /var/www/api/vendor/autoload_runtime.php:29\n    Vanta\\Integration\\Symfony\\Temporal\\Runtime\\TemporalRunner->run()\n#18 /var/www/api/public/index.php:7\n    require_once(\"\\/var\\/www\\/api\\/vendor\\/autoload_runtime.php\")",
          "encodedAttributes": null,
          "cause": null,
          "applicationFailureInfo": {
            "type": "BadMethodCallException",
            "nonRetryable": false,
            "details": null
          }
        },
        "retryState": "RetryPolicyNotSet",
        "workflowTaskCompletedEventId": "4",
        "newExecutionRunId": ""
      }
    }
  ]
}

Environment/Versions

temporal/sdk v2.8.1 temporal server v1.22.4

root-aza avatar May 17 '24 07:05 root-aza