Invalid file revision returned by JSON:API

Created on 11 October 2023, about 1 year ago

Problem/Motivation

Hi, I have a problem with invalid file revisions returned on their JSON:API resources.

I have a media type called Document, which can be translated to EN and NB languages. This media type is used mostly for uploading PDF files, but I need a different PDF for EN and NB language. For EN translations (which is a default language) everything works good, but it doesn't for NB language.

Steps to reproduce

  1. Create Document media type.
  2. Add File field and make it translatable (for ex. to EN and NB langauges).
  3. Create a Document media and add some PDF file in it (for ex. en.pdf).
  4. Translate this media and add a different PDF file in it (for ex. nb-01.pdf).
  5. Edit second translation, remove its file and upload a new one (for ex. nb-02.pdf).
  6. Go to /en/jsonapi/media/document resource and compare it with /nb/jsonapi/media/document resource.

Now, if you go to those resources, find the corresponding media, in my case (for NB lang):

{
  "type": "media--document",
  ...
  "relationships": {
    "field_media_file": {
      "data": {
        "type": "file--file",
        ...
      },
      "links": {
        "related": {
          "href": "http://localhost:8080/nb/jsonapi/media/document/5982ce2e-68ee-453d-88b7-4097702760b0/field_media_file?resourceVersion=id%3A721"
        },
      }
    }
  }
}

Let's focus on relationships.field_media_file.links.related.href ... if you go to this resource "http://localhost:8080/nb/jsonapi/media/document/5982ce2e-68ee-453d-88b7-4097702760b0/field_media_file?resourceVersion=id%3A721" you should see an old/previous version of the PDF file for NB lang ... so a nb-01.pdf file, instead of nb-02.pdf.

For EN language I didn't notice such issue, everything looks to be OK here.

What's interesting, if you go to the file resource without resourceVersion param in the URL (http://localhost:8080/nb/jsonapi/media/document/5982ce2e-68ee-453d-88b7-4097702760b0/field_media_file) then it works correctly.

🐛 Bug report
Status

Postponed: needs info

Version

9.5

Component
JSON API 

Last updated about 7 hours ago

Created by

🇵🇱Poland tivi22

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024