Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
root-aza opened this issue May 23, 2025 · 0 comments
Open

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

root-aza opened this issue May 23, 2025 · 0 comments
Labels
Bug Something isn't working

Comments

@root-aza
Copy link
Contributor

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 <v.shashkov@pos-credit.ru>
 * @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 root-aza added the Bug Something isn't working label May 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant