Skip to content

FileAdapter errors ignored #661

Closed

Description

@simonbengtsson

If a FileAdapter returns an error it is later ignored in the file router:

// FileRouter.js
}).catch((err) => {
  // err is ignored
  next(new Parse.Error(Parse.Error.FILE_SAVE_ERROR, "Could not store file"));
});

The S3Adapter for example returns an error with the following message when the keys are wrong: The request signature we calculated does not match the signature you provided. Check your key and signing method. Would it somehow be possible to propagate this error to the developer?

Activity

  1. simonbengtsson commented on Feb 26, 2016

    @simonbengtsson
    ContributorAuthor

    I thought of making a PR, but I'm not entirely sure what would be best here. Simply replacing the "Could not store file" message with the one from the adapter like this?

    // FileRouter.js
    }).catch((err) => {
      next(new Parse.Error(Parse.Error.FILE_SAVE_ERROR, err));
    });
  2. chriscborg commented on Feb 26, 2016

    @chriscborg
    Contributor

    Hi @simonbengtsson - This line worked for me if it helps:

    // FileRouter.js
    }).catch((err) => {
      next(new Parse.Error(Parse.Error.FILE_SAVE_ERROR, 'Could not store file: ' + err));
    });

    So I guess your code should work as well.

  3. simonbengtsson commented on Feb 26, 2016

    @simonbengtsson
    ContributorAuthor

    The question I guess is how much the adapters should be able to choose what error messages get sent to the developer. Probably it makes sense to let the adapters fully decide. It will require some changes to the adapters though to make them send better formatted errors.

  4. flovilmart commented on Mar 1, 2016

    @flovilmart
    Contributor

    There will be a need in the files adapter to return a 'standard' response as for now, when you save through the GridStore adapter or the S3Adpater, the responses differs. The FilesController is ignoring that response and returning a pre-cooked one.

  5. simonbengtsson commented on Mar 1, 2016

    @simonbengtsson
    ContributorAuthor

    Should the goal be that every subclass of FileAdapter should return a Parse.Error that can be passed directly to the user?

  6. flovilmart commented on Mar 1, 2016

    @flovilmart
    Contributor

    that would be nice to have something standard yes, doesn't have to be a Parse.Error as the *Controller is responsible for formatting

  7. parthtiwari65 commented on Mar 5, 2016

    @parthtiwari65

    Where can I find the file, " FileRouter.js " to make these changes?

    I don't see this file in my Parse server copy.

  8. hawkit commented on Mar 10, 2016

    @hawkit

    @flovilmart I have changed FileRouter.js as following : next(new Parse.Error(Parse.Error.FILE_SAVE_ERROR, 'Could not store file: ' + err)); at EC2 instance. but why i still get same error as

    [Error]: Could not store file. (Code: 130, Version: 1.12.0)

    Do I need to restart EBS to make it work?

  9. jdzorz commented on Mar 10, 2016

    @jdzorz

    @parthtiwari65 it is under node_modules/parse-server/lib/controllers/FilesController.js

    @hawkit yes restart your EBS

  10. hawkit commented on Mar 11, 2016

    @hawkit

    @parthtiwari65 it is here: /var/app/current/node_modules/parse-server/lib/Routers/FilesRouter.js

  11. hawkit commented on Mar 11, 2016

    @hawkit

    @jdzorz thanks a lot. It works!

  12. wavo89 commented on Mar 14, 2016

    @wavo89

    I'm using Heroku- how do I make sure that this change is active on the server? When I changed it and went to git add/commit/push, it said that there weren't any changes to save.

  13. abbasdawood commented on Jun 14, 2016

    @abbasdawood

    @jdzorz I can't seem to get this fixed even with parse-server (latest), on modifying the default error message this is what I see on console

    ParseError { code: 130, message: 'Could not store file.InvalidParameterType: Expected params.ContentType to be a string' }

    I understand the Parse.File constructor takes in the MIME type as the 3rd parameter, so I set this manually - which didn't help either. I also think there were some modifications in 2.1.3 to auto detect the MIME type of the uploaded file, so I don't know why MIME has to be provided anyway.

    Don't think anything is wrong with the S3 configuration / policy, since images are saving properly. This particular issue is only for .csv files.

    Any help would really be appreciated :)

  14. 5 remaining items

  15. hubertott commented on Jan 24, 2017

    @hubertott

    @abbasdawood if this was indeed your problem, perhaps we should be updating the example on this page.

    https://github.com/ParsePlatform/parse-server/wiki/Configuring-File-Adapters#passing-as-options

  16. acinader commented on Jan 24, 2017

    @acinader
    Contributor

    I think I have solved this with: #3424

    BUUUUT, read on, cause i think that there is more to do here....

    So this one has been bugging me for awhile :).

    Sometimes, an error will result in a very unhelpful: [object Object] output on console.error.

    1. Stuff should not be output on console.error. Users of parse-server should expect that errors will be output to the logger, not the console.

    2. the error message is totally useless!

    The output is coming from: the 'backstop' next() handler that is called at the end of an express request if 'something' isn't done to prevent it.

    this calls this

    In my case, the error was due to a misconfigured s3 adapter. And I fixed the lack of this particular error with this change: #3424

    But I KNOW that there are other places where the dreaded [object Object] output to console.error occurs and it would be good if we could put in a good backstop.

    SOOOOO, I see that middleware.js gets called, generates a response and then calls the final backstop in express.

    With a nice TODO: // TODO: Add logging as those errors won't make it to the PromiseRouter

    it would seem to me that three changes are needed to make a general solution that will allow us to remove that todo:

    1. Extend Parse.Error (Parse.ServerError?) to add the optional param 'Source' with the source error.

    2. log the source error in middlewares.handleParseErrors

    3. find all places where we new Parse.Error change to Paerse.ServerError and add a source error if/when appropriate...

    4. remove the next() from the end of the middlewares.handleParseErrors.

    I'm game to do it, but want to make sure I am on the right track since I'm no express expert...yet :).

    PS, it would also seem reasonable to redefine console.log, console.warn, console.error to logger.info....etc.?

  17. flovilmart commented on Jan 24, 2017

    @flovilmart
    Contributor

    @acinader, on the paper, renaming console.* makes sense, however, that could lead to unexpected behavior from cloud code for ex.

  18. acinader commented on Jan 24, 2017

    @acinader
    Contributor

    @flovilmart ok, agreed, overriding console will likely cause all kinds of havoc. how about extending Parse.Error with Parse.ServerError? Sound good to you?

  19. flovilmart commented on Jan 24, 2017

    @flovilmart
    Contributor

    Or plain Error no? There was some complaints that Parse.Error is not a subclass of Error.

  20. acinader commented on Jan 24, 2017

    @acinader
    Contributor

    k. buy that too. i'll take a crack at it.

    so i think we can hold on #3424 for now. if this works, then we can close it.

  21. self-assigned this
    on Jan 24, 2017
  22. flovilmart commented on Jan 24, 2017

    @flovilmart
    Contributor

    Excellent!

  23. added 2 commits that reference this issue on Jan 28, 2017
    e59c814
    145a1fe
  24. added a commit that references this issue on Jan 30, 2017
    f864141
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions