-
Notifications
You must be signed in to change notification settings - Fork 37
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
GraphQL error: String cannot represent value #74
Comments
I'll have to troubleshoot this in the morning but that's very weird did you tell and empty the field and renter that field? |
Thank you! 🙏🏻 I’ve tried creating a new block too with the same result. I’ll share any further context if I find anything. |
I have the same issue. I tried reentering the videos to a new block (inside NEO) and it then worked again for one site, but when switching to the other site the error appears again. 2021-05-21 08:16:14 [-][-][-][error][GraphQL\Error\Error] String cannot represent value: {"url":"https:\/\/vimeo.com\/546404759","oembed":null}
2021-05-21 08:16:14 [-][-][-][info][application] $_GET = [
'p' => 'api'
] I tried disabling/enabling |
So the GraphQL error here suggests that the JSON isn’t getting decoded somehow. I’ve witnessed JSON data getting doubly encoded before in Craft and wonder if that might be what’s happening here (i.e. after decoding the JSON, it’s actually still a string). @denisyilmaz Do you still have an example where this doesn’t work? If so, you might try putting |
yes, for example this project has this error currently live: https://www.basics.berlin/de/styling/artists/julius-forgo/projekt/bmw-vision-i-next when switchtig to english (top right) the same query with different lang param is send to the server (but there the translated oembed field returns the error above). The error is reproducable:
The language where the field is first saved in and the language first called in the frontend must not be the same to get it to work the same time. It seems a GraphQL Cache is filled with the value which then is decoded a second time when the other language is called. can that be? |
@joshuabaker i modified the line as you suggested but it still did not work: if (is_string($value) && $decValue = Json::decodeIfJson($value, true)) {
if (isset($decValue['url'])) {
return new OembedModel($decValue['url']);
}
} |
acutally, i tried differend options. this one worked once for both languages, but only if applied after the entry was saved and before the query was called the first time: if (is_string($value) && $decValue = Json::decodeIfJson($value, true)) {
if (isset($decValue['url'])) {
if(Json::isJsonObject($decValue['url'])) {
$decValue = Json::decodeIfJson($decValue['url']);
}
return new OembedModel($decValue['url']);
}
} Otherswise the backend fails on save with error, which is the expected behavior: Argument 1 passed to craft\helpers\Json::isJsonObject() must be of the type string, array given, called in /home/www/vendor/wrav/oembed/src/fields/OembedField.php on line 117 somewhere in this the value of because when I test to return only the [
{
"message": "String cannot represent value: {\"url\":{\"url\":\"https:\\/\\/vimeo.com\\/210599507\",\"oembed\":null},\"oembed\":null}",
"extensions": {
"category": "graphql"
}
}
] so it seems
|
@denisyilmaz That’s a good find. I’m seeing the same nested object in the |
To add some additional data, I am running into this as well. The error is thrown when using a YouTube URL in this format: Updating to the format below did not throw the error: |
@devinpitcher That sounds unrelated, to be honest. Are you finding that consistently with short YouTube URLs? Might be worth opening a separate issue. |
Yeah, I added four entries with short URLs, and one with a regular URL, and all the short URLs errored out but the standard URL was fine. |
@devinpitcher I think this is just a coincidence. That short URL works fine for me using the latest version. |
I get the previews, but I get the error when attempting to query via GraphQL. |
I'm currently returning |
I've had a bit of a dip into the DB and seeing how the field data is saved. It looks like something has changed recently which is causing the data to be saved in a different way: Working
Not working |
Yeah there seems to be a legacy issue thats changing it to to repeat itself inside itself. This why have been an issue from Craft 1 or 2 days BUT I think @joshuabaker your PR #75 fixes this? |
I'll update this with the looping that @denisyilmaz considered |
I tagged v1.3.8 with some testing vectors that I could think up and if you are able to change I'll get it a couple of days till I close this issue. |
After updating, I’m consistently getting an error with any embed: “String cannot represent value”
Using Craft 3.6.12.
@reganlawton Do you have any idea what might be causing that?
The text was updated successfully, but these errors were encountered: