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

[Bug] return type mismatch in Workflow::getInfo()

Open root-aza opened this issue 11 months ago • 0 comments

What are you really trying to do?

Call Workflow::getInfo() in ActivityInboundInterceptor

Describe the bug

I know that this shouldn't be done, but it seems to me that there should be a "friendly error" here as an exception, and not a typing error.

Minimal Reproduction

<?php
/**
 * Vanta Cash Bus
 *
 * @author Vlad Shashkov <[email protected]>
 * @copyright Copyright (c) 2025, The Vanta
 */

declare(strict_types=1);

namespace App\Bus\Infrastructure\Temporal;

use App\Bus\Infrastructure\Logger\BankIntegrationProcessor;
use Symfony\Component\Uid\Uuid;
use Temporal\Interceptor\ActivityInbound\ActivityInput;
use Temporal\Interceptor\ActivityInboundInterceptor;
use Temporal\Workflow;

final readonly class BankIntegrationActivityInboundInterceptor implements ActivityInboundInterceptor
{
    public function __construct(
        private BankIntegrationProcessor $applicationIdProcessor,
    ) {
    }


    public function handleActivityInbound(ActivityInput $input, callable $next): mixed
    {
        $rawApplicationId = Workflow::getInfo()->searchAttributes['applicationId'] ?? null;
        $bankId           = Workflow::getInfo()->searchAttributes['bankId'] ?? null;


        if (is_string($rawApplicationId) && is_string($bankId) && $bankId != '' ) {
            $this->applicationIdProcessor->witBankIntegration(
                Uuid::fromString($rawApplicationId),
                $bankId
            );
        }

        try {
            return $next($input);
        } finally {
            $this->applicationIdProcessor->reset();
        }
    }
}

stacktrace:

{
  "message": "Temporal\\Workflow::getInfo(): Return value must be of type Temporal\\Workflow\\WorkflowInfo, Temporal\\Activity\\ActivityInfo returned",
  "source": "PHP_SDK",
  "stackTrace": "#0  /app/src/Bus/Infrastructure/Temporal/BankIntegrationActivityInboundInterceptor.php:29\n    Temporal\\Workflow::getInfo()\n#1  /app/vendor/temporal/sdk/src/Internal/Interceptor/Pipeline.php:98\n    App\\Bus\\Infrastructure\\Temporal\\BankIntegrationActivityInboundInterceptor->handleActivityInbound(Temporal\\Interceptor\\ActivityInbound\\ActivityInput,Temporal\\Internal\\Interceptor\\Pipeline)\n#2  /app/vendor/temporal/sdk/src/Internal/Transport/Router/InvokeActivity.php:97\n    Temporal\\Internal\\Interceptor\\Pipeline->__invoke(Temporal\\Interceptor\\ActivityInbound\\ActivityInput)\n#3  /app/vendor/temporal/sdk/src/Internal/Transport/Router.php:69\n    Temporal\\Internal\\Transport\\Router\\InvokeActivity->handle(Temporal\\Worker\\Transport\\Command\\Server\\ServerRequest,array(3),React\\Promise\\Deferred)\n#4  /app/vendor/temporal/sdk/src/Worker/Worker.php:59\n    Temporal\\Internal\\Transport\\Router->dispatch(Temporal\\Worker\\Transport\\Command\\Server\\ServerRequest,array(3))\n#5  /app/vendor/temporal/sdk/src/WorkerFactory.php:308\n    Temporal\\Worker\\Worker->dispatch(Temporal\\Worker\\Transport\\Command\\Server\\ServerRequest,array(3))\n#6  /app/vendor/temporal/sdk/src/Internal/Transport/Server.php:57\n    Temporal\\WorkerFactory->onRequest(Temporal\\Worker\\Transport\\Command\\Server\\ServerRequest,array(3))\n#7  /app/vendor/temporal/sdk/src/WorkerFactory.php:290\n    Temporal\\Internal\\Transport\\Server->dispatch(Temporal\\Worker\\Transport\\Command\\Server\\ServerRequest,array(3))\n#8  /app/vendor/temporal/sdk/src/WorkerFactory.php:187\n    Temporal\\WorkerFactory->dispatch(\"\\n\ufffd7\\b\\u0013\\u0012\\u000eInvokeActivity\\u001a\ufffd\\u0006{\\\"name\\\":\\\"MigApplicationAct...\",array(3))\n#9  /app/vendor/vanta/temporal-bundle/src/Runtime/Runtime.php:33\n    Temporal\\WorkerFactory->run()\n#10 /app/vendor/vanta/temporal-bundle/src/Runtime/TemporalRunner.php:26\n    Vanta\\Integration\\Symfony\\Temporal\\Runtime\\Runtime->run()\n#11 /app/vendor/autoload_runtime.php:29\n    Vanta\\Integration\\Symfony\\Temporal\\Runtime\\TemporalRunner->run()\n#12 /app/public/index.php:8\n    require_once(\"\\/app\\/vendor\\/autoload_runtime.php\")",
  "applicationFailureInfo": {
    "type": "TypeError"
  }
}

Environment/Versions

temporal/sdk: 2.13.4

root-aza avatar May 23 '25 06:05 root-aza