responsible-ai-collaborative / aiid

The AI Incident Database seeks to identify, define, and catalog artificial intelligence incidents.
https://incidentdatabase.ai
Other
167 stars 35 forks source link

Blog – MDX + Prismic posts require all translations present to create pages #2545

Closed kepae closed 6 months ago

kepae commented 8 months ago

When creating a MDX-sourced blog post in /blog with the default lang post_name.mdx file, the absence of other languages' post_name.[LANG].mdx files for allowed languages causes errors. The error thrown is related to looking for the image file, but this issue goes away after providing the fr and es files.

We should be able to publish MDX posts even with only one .mdx file in any language.

e.g.:

workflow build: https://github.com/responsible-ai-collaborative/aiid/actions/runs/7454131080/job/20280876233?pr=2535

error Truncated page data information for the failed page "/fr/blog/deepfakes-and-child-safety/": {
  "errors": {},
  "path": "/fr/blog/deepfakes-and-child-safety/",
  "slicesMap": {},
  "pageContext": {
    "slug": "/blog/deepfakes-and-child-safety",
    "frontmatter": {
      "title": "Deepfakes and Child Safety: A Survey and Analysis of 2023 Incidents and Responses",
      "metaTitle": "Deepfakes and Child Safety: A Survey and Analysis of 2023 Incidents and Responses",
      "metaDescription": "",
      "date": "2024-01-08",
      "image": "./images/image_doj",
      "author": "REDACT"
      "slug": "/blog/deepfakes-and-child-safety"
    },
    "locale": "fr",
    "hrefLang": "fr",
    "originalPath": "/blog/deepfakes-and-child-safety/",
    "dateFormat": "DD-MM-YYYY"
  }
}
failed Building static HTML for pages - 68.224s
error Building static HTML failed for path "/fr/blog/deepfakes-and-child-safety/"

  19 |   const postImage = mdx.frontmatter.image?.childImageSharp?.gatsbyImageData?.images?.fallback?.src;
  20 |   let metaImage = null;
> 21 |   if (postImage) {
     |                   ^
  22 |     metaImage = `${config.gatsby.siteUrl}${postImage}`;
  23 |   }
  24 |   const canonicalUrl = config.gatsby.siteUrl + props.location.pathname;
clari182 commented 7 months ago

Same issue also happens on prismic. When a new language is added we need to duplicate blog posts and docs in prismic and add the new language to the language field. I think this could be improved by defaulting to en if the document is missing on prismic.

kepae commented 7 months ago

I agree. The correct behavior here is requiring only one language, and making all others optional. Ideally, we don't specify which language – we could reasonably have a post only available in Spanish – but in reality, we should start by checking for en and requiring it as a fallback.

@clari182 @pdcp1 Let's discuss this in our standup tomorrow. Or if it's blocking you today, let's discuss it on Slack. There are multiple areas we need to fix the language/translation expectations.