Skip to content

fetchAllIfNeededInBackground() error might be a server-side issue #2391

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
acegreen opened this issue Jul 25, 2016 · 4 comments
Closed

fetchAllIfNeededInBackground() error might be a server-side issue #2391

acegreen opened this issue Jul 25, 2016 · 4 comments
Labels
type:question Support or code-level question

Comments

@acegreen
Copy link

acegreen commented Jul 25, 2016

Issue Description

Two related issue detailed here:
parse-community/Parse-SDK-iOS-OSX#986
parse-community/Parse-SDK-iOS-OSX#987

Steps to reproduce

described in issues

Expected Results

fetchAllIfNeeded should return objects because objects exist.

Actual Outcome

[Error]: Object not found. (Code: 101, Version: 1.14.1)

Environment Setup

  • Server
    • parse-server version: 2.2.17
    • Operating System: Ubuntu 15.04 x64
    • Hardware: 4 GB Memory / 60 GB Disk
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): Digital Ocean
  • Database
    • MongoDB version: v3.2.7
    • Storage engine: N/A
    • Hardware: N/A
    • Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): Digital Ocean

Logs/Trace

Not sure if someone can make something of this

parse-server.info.2016-07-22.zip

@acegreen acegreen changed the title fetchAllIfNeededInBackground() error might be related to server fetchAllIfNeededInBackground() error might be a server-side issue Aug 11, 2016
@hramos
Copy link
Contributor

hramos commented Sep 6, 2016

Hey @acegreen any chance you can provide a list of repro steps? I know you covered some of this in the related issues, and in order to ensure this is a Parse Server issue it would be very useful to get a list of HTTP requests (e.g. using curl) alongside some sample data that can reliably reproduce the issue.

Bonus points if you can identify the cause and provide a PR :D

@acegreen
Copy link
Author

acegreen commented Sep 7, 2016

hey @hramos, I can certainly provide some more details to reproduce the issue. I'm not savvy enough to play around with the Parse Server repo yet. Though I recall looking into this a while ago but was able to find the root cause.

The main idea resolves around an array that contains two or more different class

Steps:

  1. Create a Test class
  2. Add an object with an array containing two elements from two different classes
  3. Try to fetchAllIfNeededInBackground

So in my case, I have my User class and I added a column called "recentSearches" which contains an array of &
Parse IOS SDK blocks against requests where the fetch is for items of different classes but that exception can be removed. So with that done, the first time the code below is executed, it can't find the results, and end up with an empty array. I then rerun the code ( in my case, just close my ViewController and reopen it, triggering the code in viewDidLoad() ) and the results appear.

I was unable to find if the results appear as part of the initial request or if its the second time around.

      if let currentUserRecentSearches = currentUser["recentSearches"] as? [PFObject] {

            PFObject.fetchAllIfNeededInBackground(currentUserRecentSearches) { (currentUserRecentSearches, error) in

                if let currentUserRecentSearches = currentUserRecentSearches as? [PFObject] {
                    self.recentSearches = currentUserRecentSearches
                    dispatch_async(dispatch_get_main_queue(), { () -> Void in
                        self.tableView.reloadData()
                    })
                }

                self.getUserRecentSearches()
            }
        }

@flovilmart
Copy link
Contributor

Can you provide the logs please?

@flovilmart
Copy link
Contributor

Given the code in the iOS SDK (and my last comment) that makes sense it fails as the fetchAll call will run a query with the className of the 1st object.

Don't pass arrays with mixed objects classNames to that method, and you should be good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:question Support or code-level question
Projects
None yet
Development

No branches or pull requests

4 participants