appdotnet / api-spec

App.net API Documentation is on the web at https://developers.app.net. Source for these docs is in the new-docs branch here. Please use the issue tracker and submit pull requests! Help us build the real-time social service where users and developers come first, not advertisers.
https://developers.app.net
952 stars 99 forks source link

Inconsistent ID type in meta response object #279

Closed mattrubin closed 11 years ago

mattrubin commented 11 years ago

The values for min_id and max_id are sometimes strings and sometimes numbers. I've designed my models to always expect strings, as specified in the spec (http://developers.app.net/docs/basics/pagination/#response-metadata). After this and issue #277, I'll be adding code to check the type and convert as needed. Is it generally a safe assumption to expect ids as strings, or should developers always be prepared to handle both strings and numbers?

GET https://alpha-api.app.net/stream/0/users/1/following

{
    "meta":{
        "min_id":869313,
        "code":200,
        "max_id":895717,
        "more":true
    },
    "data":[
        ...
    ]
}

GET https://alpha-api.app.net/stream/0/posts/stream/global

{
    "meta":{
        "min_id":"2666885",
        "code":200,
        "max_id":"2666905",
        "more":true
    },
    "data":[
        ...
    ]
}
mthurman commented 11 years ago

Are those requests happening from the same app with the same migrations? The pagination_ids migration should make the min/max_ids in both of those cases strings: http://developers.app.net/docs/basics/migrations/#current-migrations. Looking briefly at the code, nothing is jumping out at me as a bug. Can you confirm whether this is happening with or without the migration?

mattrubin commented 11 years ago

Ah, a silly error on my part had those two requests being sent with different access tokens, one of which was stored from an older app without the pagination_ids migration enabled. With that migration enabled, everything works as expected.

Sorry for the false alarm!