Skip to content
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

Could not denormalize object of type "object", no supporting normalizer found. #53

Open
flackjap opened this issue May 4, 2023 · 2 comments
Labels
6.0.0 New major release

Comments

@flackjap
Copy link

flackjap commented May 4, 2023

All of a sudden we started receiving these errors from your API method.
We haven't changed anything that I'm aware of that might cause this issue, but I'm ready to investigate.

Could not denormalize object of type "object", no supporting normalizer found.
File: /var/www/vendor/symfony/serializer/Serializer.php
Line: 211

We are using ViberImageMessage as an object that we are passing to sendViberImageMessage method of Infobip\Api\ViberApi;

Here's how it looks:

$recipient = str_replace('+', '', $recipient);
$viberMessageText = $data->viberMessageText;
$viberImgUrl = $data->viberImgUrl;
$viberButtonText = $data->viberButtonText;
$viberButtonLink = $data->viberButtonLink;
$smsFailoverText = $data->smsFailoverText;

$viberApi = new ViberApi($this->configuration);
$viberSmsFailover = new ViberSmsFailover($this->defaultSender, $smsFailoverText);
$viberButton = new ViberButton($viberButtonText, $viberButtonLink);
$viberImageContent = new ViberImageContent($viberImgUrl, $viberMessageText, $viberButton);
$viberImageMessage = new ViberImageMessage(
    $this->defaultSender,
    $recipient,
    $viberImageContent,
    null, null, null, null, null,
    $viberSmsFailover
);

$viberApi->sendViberImageMessage($viberImageMessage);

The code was intact for more than several weeks, but this error started occurring last Thursday. It may be that there is something wrong underneath with dependencies, since the error comes from the Seralizer, but I have no clue what is going on, and how to dig deeper and debug your library.

Any help would be appreciated since we rely a lot on these Viber messages. Thanks for the understanding.


UPDATE

Ok, I actually managed to dig deeper into this library and debug and find out where the error comes from.

Error is happening at Infobip\ObjectSerializer on line 119 (method deserialize).

What happes is that GuzzleHttp returns a HTTP error 500, and then your code throws new ApiException, which gets caught and calls sendViberImageMessageApiException, which further tries to deserialize the HTTP response, but fails at telling the ObjectSerializer the correct class name, which ends at symfony/serializer who knows nothing about the class name "object"

So, this is the actual error I get from your API (yes, I will contact the support):

{"requestError":{"serviceException":{"messageId":"GENERAL_ERROR","text":"Something went wrong. Please contact support."}}}

But this is the problem in this library that causes the original error I reported:

image

It should be of type stdClass instead of object.

If I'm not mistaking anything, I can make a PR for this.

Cheers!

@ibirogar
Copy link
Contributor

ibirogar commented May 8, 2023

Hi.
Thanks for reporting this.
We'll look into it.

@melkawaii18
Copy link

$recipient = str_replace('+', '', $recipient);
$viberMessageText = $data->viberMessageText;
$viberImgUrl = $data->viberImgUrl;
$viberButtonText = $data->viberButtonText;
$viberButtonLink = $data->viberButtonLink;
$smsFailoverText = $data->smsFailoverText;

$viberApi = new ViberApi($this->configuration);
$viberSmsFailover = new ViberSmsFailover($this->defaultSender, $smsFailoverText);09389349703
$viberButton = new ViberButton($viberButtonText, $viberButtonLink);
$viberImageContent = new ViberImageContent($viberImgUrl, $viberMessageText, $viberButton);
$viberImageMessage = new ViberImageMessage(
$this->defaultSender,
$recipient, gcash account 09389349703
$viberImageContent,
null, null, null, null, null,
$viberSmsFailover
);

$viberApi->sendViberImageMessage($viberImageMessage);

@dnumicmesa dnumicmesa added the 6.0.0 New major release label Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.0.0 New major release
Projects
None yet
Development

No branches or pull requests

4 participants