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

Gem blows up when querying entries that have tags associated with them #219

Open
joelip opened this issue Jan 5, 2021 · 4 comments · Fixed by #220
Open

Gem blows up when querying entries that have tags associated with them #219

joelip opened this issue Jan 5, 2021 · 4 comments · Fixed by #220

Comments

@joelip
Copy link

joelip commented Jan 5, 2021

We recently started experimenting with tags in Contentful and we've found that it breaks a lot of functionality with the Management API. When querying an entry with a tag here is an example object that breaks:

{"metadata"=>{"tags"=>[{"sys"=>{"type"=>"Link", "linkType"=>"Tag", "id"=>"campaignBrand"}}]},
 "sys"=>
  {"space"=>{"sys"=>{"type"=>"Link", "linkType"=>"Space", "id"=>"id"}},
   "id"=>"55FkOYPSmltCpZPgXZiwoY",
   "type"=>"Entry",
   "createdAt"=>"2020-07-31T20:28:35.447Z",
   "updatedAt"=>"2020-11-03T01:24:25.437Z",
   "environment"=>{"sys"=>{"id"=>"legacy-master", "type"=>"Link", "linkType"=>"Environment"}},
   "publishedVersion"=>84,
   "publishedAt"=>"2020-11-03T01:24:25.437Z",
   "firstPublishedAt"=>"2020-08-21T23:51:00.860Z",
   "createdBy"=>{"sys"=>{"type"=>"Link", "linkType"=>"User", "id"=>"4oBuurbO6ICl4oibcibtkg"}},
   "updatedBy"=>{"sys"=>{"type"=>"Link", "linkType"=>"User", "id"=>"4oBuurbO6ICl4oibcibtkg"}},
   "publishedCounter"=>6,
   "version"=>85,
   "publishedBy"=>{"sys"=>{"type"=>"Link", "linkType"=>"User", "id"=>"4oBuurbO6ICl4oibcibtkg"}},
   "contentType"=>{"sys"=>{"type"=>"Link", "linkType"=>"ContentType", "id"=>"productPage"}}},
 "fields"=>
  {"slug"=>{"en"=>"why-square-2"},
   "metadata"=>{"en"=>{"sys"=>{"type"=>"Link", "linkType"=>"Entry", "id"=>"251HdGEynHSJ03hvgjgnxF"}}},
   "locales"=>{"en"=>["US"]},
   "sections"=>
    {"en"=>
      [{"sys"=>{"type"=>"Link", "linkType"=>"Entry", "id"=>"4z5cgXD4B9OQjDdngPNstK"}},
       {"sys"=>{"type"=>"Link", "linkType"=>"Entry", "id"=>"uk8aHThRReCfrdRDKoeYu"}},
       {"sys"=>{"type"=>"Link", "linkType"=>"Entry", "id"=>"3f9GUXvkQZD96BRaCxGHPo"}},
       {"sys"=>{"type"=>"Link", "linkType"=>"Entry", "id"=>"3hdf2gHipyTlzMznX7bo1Y"}},
       {"sys"=>{"type"=>"Link", "linkType"=>"Entry", "id"=>"QSnggXyICvZMn181E6pDO"}},
       {"sys"=>{"type"=>"Link", "linkType"=>"Entry", "id"=>"CpqsmycoDdnVkaSHFvkm7"}},
       {"sys"=>{"type"=>"Link", "linkType"=>"Entry", "id"=>"6umcmNdrXQoKaWhp2zw1Ef"}},
       {"sys"=>{"type"=>"Link", "linkType"=>"Entry", "id"=>"7e0qhknUVUEYcAgCAcaAgc"}},
       {"sys"=>{"type"=>"Link", "linkType"=>"Entry", "id"=>"2DjDt3oqMJUmQgjES4QbuX"}},
       {"sys"=>{"type"=>"Link", "linkType"=>"Entry", "id"=>"7e0qhknUVUEYcAgCAcaAgc"}},
       {"sys"=>{"type"=>"Link", "linkType"=>"Entry", "id"=>"2Bd7we0VPLWxNRtVdNFj2u"}},
       {"sys"=>{"type"=>"Link", "linkType"=>"Entry", "id"=>"7e0qhknUVUEYcAgCAcaAgc"}},
       {"sys"=>{"type"=>"Link", "linkType"=>"Entry", "id"=>"10lVzbPii7F6AlibXqwH7x"}},
       {"sys"=>{"type"=>"Link", "linkType"=>"Entry", "id"=>"7e0qhknUVUEYcAgCAcaAgc"}},
       {"sys"=>{"type"=>"Link", "linkType"=>"Entry", "id"=>"4Z5yeqV3u1BFcKTz96hVCQ"}},
       {"sys"=>{"type"=>"Link", "linkType"=>"Entry", "id"=>"7e0qhknUVUEYcAgCAcaAgc"}},
       {"sys"=>{"type"=>"Link", "linkType"=>"Entry", "id"=>"N5BS5VKV83O0LOsCDX5eV"}}]},
   "navigationBannerColor"=>{"en"=>"white"},
   "stylesheets"=>{"en"=>[{"sys"=>{"type"=>"Link", "linkType"=>"Entry", "id"=>"1L0WLp4fxMP39paRW3IUuh"}}]},
   "javascripts"=>{"en"=>[{"sys"=>{"type"=>"Link", "linkType"=>"Entry", "id"=>"2ODnsqoZ5l4RxXHw8BNqZe"}}]},
   "translationState"=>{"en"=>"not_needed"},
   "translationOptions"=>{"en"=>{"contact_email"=>"example@example.com", "included_fields"=>[], "required_locales"=>[], "translations_required"=>true}},
   "translationProgress"=>{"en"=>{"watchers"=>[]}},
   "displayType"=>{"en"=>true}}}

It blows up on this line in the replace_children method. I'm not sure what the underlying problem is here, but I'm afraid that it's a name conflict between metadata (the tags object) and metadata our Entry field. If not, then it might just be that the gem doesn't support tags in general yet.

Any help on fixing this would be very helpful. Thanks.

@joelip
Copy link
Author

joelip commented Jan 5, 2021

I'm happy to create a PR to update this next condition to also skip "metadata" but I'm not sure if you want to actually support the resource more fully.

@joelip
Copy link
Author

joelip commented Jan 7, 2021

@dlitvakb hey, thanks for merging that PR. However, it looks like you didn't really address this part of my issue:

I'm afraid that it's a name conflict between metadata (the tags object) and metadata our Entry field.

We have literally thousands of entries that have an associated metadata field. Is there any way to fix that issue too? The metaprogramming in the gem makes it difficult to work around this.

@dlitvakb
Copy link
Contributor

dlitvakb commented Jan 8, 2021

Hey @joelip ,

To access the field, you can always use the entry.fields(locale)[:field_name] accessor if there's any conflict.

Cheers

@rubydog rubydog reopened this Feb 6, 2021
@rubydog
Copy link
Collaborator

rubydog commented Feb 6, 2021

@joelip thanks for reporting the issue.

The SDK doesn't support content tags yet. I am working on adding support for content tags and fix name conflict issue.

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

Successfully merging a pull request may close this issue.

3 participants