[SOLVED] Asset URLs get version parameter that leads to 404

I have…

  • [ ] Checked the logs and have provided uploaded a log file and provided a link because I found something suspicious there.

I don’t have access to the container that Squidex is running in. If required, I can ask someone to get the logs.

I’m submitting a…

  • [ ] Regression (a behavior that stopped working in a new release)
  • [x ] Bug report
  • [ ] Performance issue
  • [ ] Documentation issue or request

Issue description

When uploading an asset and changing the slug, the version number increases somewhere internally (as expected). I have assets linked in another object and I use GraphQL to fetch it’s URL with something like this:

{
  querySomeContents {
    data {
      assets {
        url
      }
    }
  }
}

with data/assets being Asset[]

The retrieved URL is https://my-hostname/api/assets/<uuid>?version=1
However, a GET request to that URL will always result in a 404 response. The asset is only available when ?version=0 is queried.

Uploading an asset and retrieving it works, it starts failing upon the first change on the asset which increases the issued version number.

Environment

  • [x] Self hosted with docker
  • [ ] Self hosted with IIS
  • [ ] Self hosted with other version
  • [ ] Cloud version

Version: 4.0.3.0

Hi and welcome to Squidex :slight_smile:

I am not sure if I understand your issue.

But an asset has two versions: File version and entity version. In this case the version is the file version that gets only updated when you replace the file with a new one.

Thanks for the welcome and fast response!

If the asset has two versions, I think the problem might be that I get the entity version appended to the URL when querying an the URL of an asset. I can reproduce it easily tho:

Create a simple single-content schema test-schema like this:

{
    "properties": {},
    "scripts": {},
    "fieldsInLists": [],
    "fieldsInReferences": [],
    "fields": [
        {
            "name": "assets",
            "properties": {
                "fieldType": "Assets"
            },
            "partitioning": "invariant"
        }
    ],
    "isPublished": true
}

Then upload an asset, change something like the slug, to increase the entity version and link it to the schema we just created.

Then head to the GraphQL panel and query the URL with this:

{
  queryTestSchemaContents {
    data {
      assets {
        iv {
          url
        }
      }
    }
  }
}

The result I get looks like this:

{
  "data": {
    "queryTestSchemaContents": [
      {
        "data": {
          "assets": {
            "iv": [
              {
                "url": "https://my-hostname/api/assets/1c923190-25d3-46e6-8066-7d5c97b548d2?version=2"
              }
            ]
          }
        }
      }
    ]
  }
}

The problem is, sending a GET request to this URL will always give me 404 as response. It only works when I change the ?version=2 to ?version=0 or just drop it entirely.

So my guess is that the generated URL is incorrectly referring to the entity version.

best regards
Alex

Okay, I get it. This is indeed a bug in the URL generator.

It is fixed in the current dev version.