Skip to content
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

BUG: iPhone app cannot retrieve playlist tracks from API #89

Closed
adrienjoly opened this issue Aug 13, 2017 · 7 comments
Closed

BUG: iPhone app cannot retrieve playlist tracks from API #89

adrienjoly opened this issue Aug 13, 2017 · 7 comments
Assignees
Labels
Projects

Comments

@adrienjoly
Copy link
Member

Reported by Arasg:

quand je veux aller dans mes playlists, j'ai un message qui me dit que je n'ai pas encore ajouté de titres alors que c'est faux...38

Continuation of openwhyd/openwhyd-ios#1

=> API calls made by the iOS app are to be tested on the back-end

@adrienjoly adrienjoly created this issue from a note in Development (⚙ In progress) Aug 13, 2017
@adrienjoly adrienjoly moved this from ⚙ In progress to 📓 Backlog / Next in Development Aug 13, 2017
@adrienjoly adrienjoly moved this from 📓 Backlog / Next to ⚙ In progress in Development Aug 17, 2017
@adrienjoly adrienjoly self-assigned this Aug 17, 2017
@adrienjoly
Copy link
Member Author

adrienjoly commented Aug 17, 2017

resolution steps:

  • write a failing API test that creates a playlist with a track, then checks that the playlist contains that track, using same API call as the iPhone app
  • make the test pass by fixing the problem
  • push fix to production and ask Arasg if it solves the problem

@adrienjoly
Copy link
Member Author

For reference, the urls of the iOS app's API calls are in that file: https://github.com/openwhyd/openwhyd-ios/blob/d700d5b45242301591fb5f098d1be4153b54f2b2/Whyd/Config.h#L125

@adrienjoly
Copy link
Member Author

adrienjoly commented Aug 17, 2017

Getting the following error in production, when trying to open a playlist from the iOS app:

$ tail -F appd.err

===
Thu, 17 Aug 2017 13:54:02 GMT Error
    at Console.error (/home/adrien/openwhyd/whydJS/app.js:23:45)
    at /home/adrien/openwhyd/whydJS/app/models/post.js:78:13
    at handleCallback (/home/adrien/openwhyd/whydJS/node_modules/mongodb/lib/utils.js:120:56)
    at /home/adrien/openwhyd/whydJS/node_modules/mongodb/lib/cursor.js:857:22
    at handleCallback (/home/adrien/openwhyd/whydJS/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:171:5)
    at /home/adrien/openwhyd/whydJS/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:585:22
    at queryCallback (/home/adrien/openwhyd/whydJS/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:212:16)
    at /home/adrien/openwhyd/whydJS/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js:469:18
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
    at process._tickCallback (internal/process/next_tick.js:104:9)
model.fetchPosts ERROR on query { uId: '4d94501d1f78ac091dbc9b4d', 'pl.id': 61 } with params { sort: [ [ 'order', 'asc' ], [ '_id', 'desc' ] ],
  limit: '1000,201' } : { MongoError: Failed to parse: { find: "post", filter: { uId: "4d94501d1f78ac091dbc9b4d", pl.id: 61 }, sort: { order: 1, _id: -1 }, limit: "1000,201" }. 'limit' field must be numeric.
    at Function.MongoError.create (/home/adrien/openwhyd/whydJS/node_modules/mongodb/node_modules/mongodb-core/lib/error.js:31:11)
    at queryCallback (/home/adrien/openwhyd/whydJS/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:212:36)
    at /home/adrien/openwhyd/whydJS/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js:469:18
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
    at process._tickCallback (internal/process/next_tick.js:104:9)
  name: 'MongoError',
  message: 'Failed to parse: { find: "post", filter: { uId: "4d94501d1f78ac091dbc9b4d", pl.id: 61 }, sort: { order: 1, _id: -1 }, limit: "1000,201" }. \'limit\' field must be numeric.',
  waitedMS: 0,
  ok: 0,
  errmsg: 'Failed to parse: { find: "post", filter: { uId: "4d94501d1f78ac091dbc9b4d", pl.id: 61 }, sort: { order: 1, _id: -1 }, limit: "1000,201" }. \'limit\' field must be numeric.',
  code: 9 }

... while processing that request:

$ tail -F appd.out

=== Thu, 17 Aug 2017 13:54:02 GMT GET /u/4d94501d1f78ac091dbc9b4d/playlist/61 (userLibrary.controller) {"format":"json","limit":["1000","20"],"id":"4d94501d1f78ac091dbc9b4d","playlistId":"61"}
fetching user  { _id: 4d94501d1f78ac091dbc9b4d } ...
fetchPlaylists: 43.156ms
fetchStats: 22.654ms
fetchLikes: 1.150ms
fetchNbTracks: 8.472ms
=> fetched 0 posts
fetchAndRender: 3.656ms

Anomaly: as seen in appd.out, the GET parameters of the request are parsed into an object that contains an array of two values for the limit parameter: ["1000","20"] (it should be just one integer value. 1000, according to https://github.com/openwhyd/openwhyd-ios/blob/d700d5b45242301591fb5f098d1be4153b54f2b2/Whyd/Config.h#L149)

Consequence: in the corresponding db query, the value of limit is passed as "1000,201", whereas mongodb expects an integer. Probably because the limit array (["1000","20"], as parsed from GET parameters) were casted into a string (=> "1000,20"), thus adding 1 to it resulted in a concatenation (=> "1000,201").

Diagnostic:

Hypothesis:

@adrienjoly
Copy link
Member Author

adrienjoly added a commit that referenced this issue Aug 18, 2017
(for diagnosis of bugs from external clients, like #89)
@adrienjoly
Copy link
Member Author

Progress: was able to reproduce the bug, by providing two values of the same limit parameter in the playlist track request: ?...&limit=1000&limit=20

=> next step: check if the iOS does this.

@adrienjoly
Copy link
Member Author

adrienjoly commented Aug 18, 2017

After activating the logging of GET parameters of incoming requests on openwhyd.org, I used the iOS app to open a playlist, and observed the following trace:

=== Fri, 18 Aug 2017 11:48:07 GMT GET /u/4d94501d1f78ac091dbc9b4d/playlist/61?format=json&limit=1000&limit=20 (userLibrary.controller) {"format":"json","limit":["1000","20"],"id":"4d94501d1f78ac091dbc9b4d","playlistId":"61"}
fetching user  { _id: 4d94501d1f78ac091dbc9b4d } ...
fetchPlaylists: 14.517ms
fetchStats: 11.812ms
fetchLikes: 1.001ms
fetchNbTracks: 9.095ms
=> fetched 0 posts
fetchAndRender: 5.602ms

=> the iOS app is indeed sending two values for the limit parameter: /u/4d94501d1f78ac091dbc9b4d/playlist/61?format=json&limit=1000&limit=20, which is probably causing the bug.

@adrienjoly
Copy link
Member Author

Proposed solution:

adrienjoly added a commit that referenced this issue Aug 18, 2017
@adrienjoly adrienjoly moved this from ⚙ In progress to ✔️ Done / pending QA in Development Aug 18, 2017
adrienjoly added a commit that referenced this issue Sep 13, 2017
Issue #89: iPhone app cannot retrieve playlist tracks from API
@adrienjoly adrienjoly moved this from ✔️ Done / pending QA to 🌲 In production in Development Sep 13, 2017
Development automation moved this from 🌲 In production to ✔️ Done / pending QA Nov 26, 2017
@adrienjoly adrienjoly moved this from ✔️ Done / pending QA to 🌲 In production in Development Nov 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development
  
🌲 In production
Development

No branches or pull requests

1 participant