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

Inconsistent API Results #138

Closed
rivendare opened this issue May 30, 2017 · 5 comments
Closed

Inconsistent API Results #138

rivendare opened this issue May 30, 2017 · 5 comments

Comments

@rivendare
Copy link

rivendare commented May 30, 2017

We're using Contentful on our Production environment to fetch an entry (which has various nested containers / entries) to populate our home page, but today we had an issue that took down our site: one of the entries within one of the nested containers is returning a Contentful::Link instead of the expected Contentful::Asset (which it had been returning previously).

As expected, this caused a sudden and rather catastrophic failure when it threw an error trying to fetch an image.url property off a Link instead of an Asset.

I've tried initializing the client with all sorts of properties through the documentation, e.g. max_include_resolution_depth, include, etc., but none seem to change why it's returning this.
Was there any recent API change that would've resulted in this?

What's strange is if we hit the Preview API in the same space, for the exact same object (identical ID), it resolves as an Asset. 🤔

@dlitvakb
Copy link
Contributor

dlitvakb commented Jun 6, 2017

Hey @rivendare,

Looks like your Asset has been unpublished, the CDA does not return unpublished Assets/Entries, while CPA does.

Cheers

@hugobast
Copy link
Contributor

I have this issue currently but it only appears when we put a cache on an object. When I receive this object from contentful directly I get an Asset when it's a cache hit I sometimes get an Asset but some other time I get a Link. This is quite apparent because out of a collection of two things one has an image of type Asset while the second has an image of type Link. This is really problematic and the marshal_load is not the easiest to understand.

@hugobast
Copy link
Contributor

More data on this:

> hero = array.first
<Contentful::Entry[heroBlock] id='5P9m6KMsCcAaYIMoYOAYke'>

> hero.rollovers.first.image1
<Contentful::Asset id='24Pkaei6uk06qi4SuOgS0E' url='//images.contentful.com/<redacted>/callout-right-img-1.jpg'>

> hero.rollovers.first.image2
<Contentful::Asset id='24Pkaei6uk06qi4SuOgS0E' url='//images.contentful.com/<redacted>/callout-right-img-1.jpg'>

> hero.rollovers.second.image1
<Contentful::Link id='4U29S5aIn6cQyG2eI2C2iW'>

> hero.rollovers.second.image2
<Contentful::Link id='4U29S5aIn6cQyG2eI2C2iW'>

Only one of the associations' images made it back from the cache as an `Asset`

@hugobast
Copy link
Contributor

I've delved into this some more over the week end, I clearly see two instances of Contentful::Asset#marshal_dump called instead of the expected four. I don't know where to look next, in Contentul::FieldsResource#marshal_dump if I print the value of raw_with_links I can clearly see for both rollovers that I have image1 and image2 of type Contentful::Asset. Yet when the dumping is done the bottom two images (1 and 2) don't have the correct type and data (it's now a Contentful::Link).

I also printed in raw_with_links to see if somehow links.include?(Support.snakify(k).to_sym) would be false, and it is true always. Completely baffled...

@dlitvakb
Copy link
Contributor

Found the cause of this issue,

About to release a patch.

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants