Calling Developers!
We are reenergizing our code contribution process! Learn More

What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Hi. I'm trying to start with Spryker but unfortunately having troubles at very beginning. In develop

Options
U01NZPTR6P8
U01NZPTR6P8 Posts: 8 🧑🏻‍🚀 - Cadet

Hi. I'm trying to start with Spryker but unfortunately having troubles at very beginning. In developer bootcamp, there is a challenge to communicate Yves with Zed. I implemented everything mentioned in description, but calling Yves endpoint I got following error:

"RuntimeException: Controller 'Pyz\Zed\Unixslayer\Communication\Controller\GatewayController::reverseAction()' requires that you provide a value for the '$transfer' argument. Either the argument is nullable and no null value has been provided, no default value has been provided or because there is a non optional argument after this one. in file /data/vendor/symfony/http-kernel/Controller/ArgumentResolver.php on line 80"

After investigating a bit deeper, I found that request, which is send to Zed is created with empty stream. Followup with objects dumped right before Zed call.

Spryker\Client\ZedRequest\Client\Request {#1138
  #values: array:8
    "host" => "a04cc4aa7478"
    "metaTransfers" => array:2
      "locale" => array:2
        "data" => array:4
          "locale_name" => "en_US"
          "id_locale" => null
          "name" => null
          "is_active" => null
        ]
        "className" => "Generated\Shared\Transfer\LocaleTransfer"
      ]
      "currency" => array:2
        "data" => array:6
          "code" => "EUR"
          "symbol" => "€"
          "id_currency" => null
          "name" => "Euro"
          "is_default" => true
          "fraction_digits" => 2
        ]
        "className" => "Generated\Shared\Transfer\CurrencyTransfer"
      ]
    ]
    "password" => null
    "sessionId" => "7cc997352356cbd15bf0546716418b5e"
    "time" => "1616096479"
    "transfer" => array:1
      "original_string" => "Hello world!"
    ]
    "transferClassName" => "Generated\Shared\Transfer\StringReverseTransfer"
    "username" => null
  ]
}

GuzzleHttp\Psr7\Request {#1161
  -method: "POST"
  -requestTarget: null
  -uri: GuzzleHttp\Psr7\Uri {#1160
    -scheme: "http"
    -userInfo: ""
    -host: "zed.us.spryker.local"
    -port: null
    -path: "/unixslayer/gateway/reverse"
    -query: ""
    -fragment: ""
  }
  -headers: array:6
    "Host" => array:1
      0 => "zed.us.spryker.local"
    ]
    "User-Agent" => array:1
      0 => "Yves 2.0"
    ]
    "X-Yves-Host" => array:1
      0 => "1"
    ]
    "X-Internal-Request" => array:1
      0 => "1"
    ]
    "Auth-Token" => array:1
      0 => "JDJ5JDA0JElvOC96LzEuVEltYnhHYVRXdFgwY09aR01GVy9hYVpybktleGJFLnJZUVRORzJSWTE4Zmc2"
    ]
    "X-Request-ID" => array:1
      0 => "7bb946bc"
    ]
  ]
  -headerNames: array:6
    "user-agent" => "User-Agent"
    "x-yves-host" => "X-Yves-Host"
    "x-internal-request" => "X-Internal-Request"
    "auth-token" => "Auth-Token"
    "x-request-id" => "X-Request-ID"
    "host" => "Host"
  ]
  -protocol: "1.1"
  -stream: null
}

Comments

  • hey! Sorry for getting back to you so late. Can you show the GatewayController you created? and also the ZedStub?

  • U01NZPTR6P8
    U01NZPTR6P8 Posts: 8 🧑🏻‍🚀 - Cadet
    Options

    @UJN2JRU4F looks like no $argumentValueResolvers are passed into \Symfony\Component\HttpKernel\Controller\ArgumentResolver so it takes default ones and none of them could resolve gateway argument from the request. I saw two implementations of \Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface in Spryker codebase. How exactly is Symfony components configured in Spryker? Is Spryker using autowire/autoconfig?

  • hi

  • no autowire/autoconfig by any means

  • gateway controller looks fine

  • stub as well

  • let’s follow the chain further

  • my line of thought: this is a very frequently done and rather mature task, so the basic configuration is likely correct, otherwise people would stumble often. so there is probably some detail off.

  • following a principle from the Pragmatic Programmer: “If you see hoof prints think horses, not zebras. ” 😊

  • so, now we have to find out where the Stub is actually used. Following the error message, this would probably be the controller

  • U01NZPTR6P8
    U01NZPTR6P8 Posts: 8 🧑🏻‍🚀 - Cadet
    Options

    I'll follow the rabbit hole and return to you with the results 😉

  • You could also share a gut diff with your code or so 😊

  • U01NZPTR6P8
    U01NZPTR6P8 Posts: 8 🧑🏻‍🚀 - Cadet
    Options

    @UJN2JRU4F Turned out that my GatewayController extends AbstractController instead of AbstractGatewayController. Everything started to work as expected after change. I was trying to debug this issue more further but decided to go again with the example and copy/paste code samples from training and checking if I did something different. At first attempt I was writing the code by my own.

  • happens 🤷

  • Unknown
    edited March 2021
    Options

    do you have any suggestion what might have helped you identify or even prevent the mistake from our side?

  • U01NZPTR6P8
    U01NZPTR6P8 Posts: 8 🧑🏻‍🚀 - Cadet
    Options

    For this case? Maybe in tutorial you can emphasize that there is a difference between AbstractController and AbstractGatewayController. I read the description, made a brief look at GatewayController and started to code. Going with copy/paste I could not even notice that. AbstractGatewayController works differently from AbstractController although implementations are made in the same namespace which can be a bit confusing. I think that this should be explained somewhere.

  • U01NZPTR6P8
    U01NZPTR6P8 Posts: 8 🧑🏻‍🚀 - Cadet
    Options

    I just noticed, that actions in AbstractGatewayControllers can only accept TransferObjects so it works totally different from AbstractControllers . Took a quick look at documentation, but I don't see any explanation, that they have specific purpose.

  • the gateway controllers?

  • this is indeed the closes thing i found (after 5 mins of search) https://documentation.spryker.com/docs/client#requests-from-yves-to-zed

  • U01NZPTR6P8
    U01NZPTR6P8 Posts: 8 🧑🏻‍🚀 - Cadet
    Options

    @UJN2JRU4F it still doesn't explain the difference between GatewayController and standard Controller. But I guess that this might not be that much of a problem if this is the first time someone had this issue. On the other hand, it could be helpful to point out the purpose and how GatewayControllers actually works.

  • agreed