Error " [INVALID_FOREIGN_KEY] Invalid foreign key." uploading files

Directus version 11.8.1 running in Docker.

I set up Directus locally using Docker and everything worked fine. I then moved the container to my production server. I copied the external volumes containing uploads and the SQlite database. Again, it all worked. My application read from the API and the app mostly worked.

However, I can no longer upload files in the files area (or in a file field in a collection). I get the above error and the logs show…

[06:19:53] GET /files?filter[_and][0][type][_nnull]=true&filter[_and][1][folder][_null]=true&aggregate[countDistinct]=id 200 19ms
[06:19:53.066] ERROR: The "path" argument must be of type string. Received null
    err: {
      "type": "TypeError",
      "message": "The \"path\" argument must be of type string. Received null",
      "stack":
          TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received null
              at join (node:path:1268:7)
              at DriverLocal.fullPath (file:///directus/node_modules/.pnpm/@directus+storage-driver-local@file+packages+storage-driver-local/node_modules/@directus/storage-driver-local/dist/index.js:14:28)
              at DriverLocal.exists (file:///directus/node_modules/.pnpm/@directus+storage-driver-local@file+packages+storage-driver-local/node_modules/@directus/storage-driver-local/dist/index.js:44:24)
              at AssetsService.getAsset (file:///directus/node_modules/.pnpm/@directus+api@file+api_@types+node@22.13.8_@unhead+vue@1.11.20_vue@3.5.13_typescript@5.8.2____jigekj2vspo2admkgggvl64evi/node_modules/@directus/api/dist/services/assets.js:54:61)
              at async file:///directus/node_modules/.pnpm/@directus+api@file+api_@types+node@22.13.8_@unhead+vue@1.11.20_vue@3.5.13_typescript@5.8.2____jigekj2vspo2admkgggvl64evi/node_modules/@directus/api/dist/controllers/assets.js:154:36
      "code": "ERR_INVALID_ARG_TYPE"
    }

Any ideas?

Are there any differences between the environment variables and the configuration between your local and production setups?

If you’re using SQLite, obviously it’s just a file, so that should work okay. But it seems like your production setup and your local setup are different.