question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Definition of `Asset` type is wrong - failing content validation

See original GitHub issue

Expected Behavior

Type definition of Asset should match the actual content that is returned from the API.

Actual Behavior

  1. sys: Asset uses the general definition of sys, which requires a contentType entry. However, Asset does not include it. This is the main blocker for us (at Intercom).
  2. title is declared as required - but it is not required by Contentful’s App/UI
  3. description is declared as required - but it is not required by Contentful’s App/UI

Possible Solution

  1. Fork the definition of sys so Asset could have it’s own sys definition which does not include contentType
  2. Change definition of title and description to be optional

Steps to Reproduce

  1. Create an Asset on Contentful (see that you can leave the title and description empty)
  2. Export the asset’s JSON (either by API or by reloading the Contentful page and inspecting the network request in the browser)
  3. See that the returned response does not contain a contentType node

Context

This blocks us from validating our content when deploying to production. Here at Intercom we “export” all the content (as JSON) through the Content Delivery API upon deployment - and validate everything with JSONSchema.

Up until now we were using “weak” validation that only verified the “fields” of each entry - but that allowed too many bad deployments (specifically - deployments with references to deleted entries). To generate the JSON schema we use typescript-json-schema. Most of the TypeScript types used for the schema are generated by our code - except for Entry and Asset that are coming from this lib.

Having this fixed would allow us to spot content issues during deployment, thus have much greater confidence in our deployments and less incidents in production.

Environment

Since this is tied directly to the code definitions I don’t believe my environment is relevant here. Omitting this to reduce noise.

Related Issues and PRs

https://github.com/contentful/contentful.js/issues/208 https://github.com/contentful/contentful.js/pull/258 https://github.com/contentful/contentful.js/pull/206

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
marcolinkcommented, Apr 27, 2022

Hey @alonre @alextiley @magnattic, we have completely rewritten the client in Typescript. This also includes better type definitions for Asset

You can check it out on npm under the beta-v10 tag (go to the “Versions” tab to find it). The migration guide and updated v10 README and can be found on the beta-v10 branch. All details on the new Typescript features can be found here.

1reaction
marcolinkcommented, Apr 28, 2022

@magnattic

created a PR to also address this issue: https://github.com/contentful/contentful.js/pull/1240

Read more comments on GitHub >

github_iconTop Results From Across the Web

Asset validation failed | Apple Developer Forums
Hi. I am trying to upload an App to the App Store. It is a Java application with a small Swift wrapper.
Read more >
Assets (Tenable.sc 5.23.x)
Combination assets allow you to create an asset based on existing assets and the AND, OR, and NOT operators. Combination assets can include...
Read more >
Errors—ArcGIS Pro | Documentation
Errors can be created for a variety of reasons, from identifying empty geometries and invalid connectivity to discovering incorrect asset types in a ......
Read more >
Utility Network: Fantastic Errors and How to Fix Them - Part1
Fix Incorrect data – Most of the time this could be incorrect data, where an incorrect asset type or asset group is used....
Read more >
Top Fixed Assets Management Challenges - Bloomberg Tax
Getting your fixed assets management wrong can lead to costly inefficiencies, ... that allows for asset type and class depreciation for different scenarios....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found