Files are not found on 4.3.0

Hey everyone!

As I’ve mentioned in other topics, I just upgraded my server from 2.8.4 to 4.3.0 and everything runs smoothly! The only issue is with the images that are stored in mongo! For some reason, the server cannot find them. The server logs;

0|index  | Error: Unsupported state or unable to authenticate data
0|index  |     at (crypto.js:183:26)
0|index  |     at (/root/parse-server-example/node_modules/parse-server/lib/Adapters/Files/GridFSBucketAdapter.js:113:78)
0|index  |     at emitNone (events.js:106:13)
0|index  |     at GridFSBucketReadStream.emit (events.js:208:7)
0|index  |     at endReadableNT (_stream_readable.js:1064:12)
0|index  |     at args.(anonymous function) (/usr/local/lib/node_modules/pm2/node_modules/event-loop-inspector/index.js:138:29)
0|index  |     at _combinedTickCallback (internal/process/next_tick.js:139:11)
0|index  |     at process._tickDomainCallback (internal/process/next_tick.js:219:9)

I checked the db to see if the file is missing, but it is there! Is it a known issue? Is there a solution?

EDIT; When I open a file from the dashboard I get;

Safari can’t open the page “‎ip:1337/parse/files/yb4kkwwr70gcdO07qZ1ywucrgRfkA4FU6TttgAgg7TS/3e84ef36611caf1cba7443fc7713eea6_postImage.jpeg” because Safari can’t connect to the server “ip”.

This is my server setup;

var api = new ParseServer({
    databaseURI: databaseUri || 'mongodb://',
    cloud: './cloud-code-repository/main.js',
    appId: process.env.APP_ID || '' ,
    masterKey: process.env.MASTER_KEY || '' ,
    fileKey: 'b5528d30-...',

    serverURL: process.env.SERVER_URL || 'http://ip:1337/parse' , 
    liveQuery: {
       classNames: ['Message', 'ChatRoom'] // List of classes to support for query subscriptions

    publicServerURL: 'http://ip:1337/parse'

Change ip value to actual ip adress

I haven’t actually put it as ip! I just wrote it here for protection reasons

Are you also upgrading MongoDB version? Are you using the same fileKey as before?

I didn’t upgrade my MongoDB because it’s on v4.0.2, so I think I don’t have to.
The fileKey is unchanged.

Can you please check if you have the same problem on 4.2.0?

1 Like

That totally worked! What changes on 4.3.0 that could affect that?

I remember there are some changes related to the way the file adapter encrypts the files. We will have to check why the upgrade is not possible, how to upgrade and mentioned that on the docs. Would you mind to open a issue in the repo?

I just did! Thanks for all the help!!

@CastAsHuman are you able to post the updated solution here just in case anyone else has this problem?

Sure! What I did was downgrade to 4.2.0 because there was a change on 4.3.0 that affected the file setup… you can learn more on this issue I opened on github:

@CastAsHuman I thought you got everything working on 4.3 after following the recommendation I gave of removing fileKey from your ParseServer initialization? If that worked, that solution is different from downgrading to 4.2

Yeah, as soon as it worked on 4.2.0 I didn’t try your suggestion, because I was very busy… when I find the time, I’ll try it and I’ll post about it!

fileKey the way you are using it is legacy Parse-server 4.3 repurposed the use of fileKey as it wasn’t being used by parse server anymore up to 4.2. I think what I mentioned about legacy parse is in the parse documentation somewhere…

In parse-server 4.3 since fileKey: 'b5528d30-... is present when initializing the ParseServer, it’s attempting to decrypt the files with that key. Removing fileKey from the parse configuaration will fix the issue.

1 Like

Update for the latest parse-server on the master branch that will go into parse-server >= 4.4.0. Having a fileKey left over from legacy won’t cause an issue anymore (it also doesn’t do anything). For file encryption using the GridStoreAdapter or FSAdapter, you can use encryptionKey. The formal documentation is here:

1 Like