mlvea / google-api-objectivec-client

Automatically exported from code.google.com/p/google-api-objectivec-client
0 stars 0 forks source link

Unexpected Assertion failure when performing a request with banned video ids #33

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Perform a query using [GTLQueryYouTube queryForVideosListWithIdentifier... 
with a set of banned videoIds
2.
3.

What is the expected output? What do you see instead?

When testing the query using 
https://developers.google.com/youtube/v3/docs/videos/list ; I do not get an 
error but rather an empty result. 

For instance if I request id: 5ff6D5SFhdM,n3Yrk2q9YlE ; part: id,snippet - "I 
got:

200 OK

- Show headers -

{
 "kind": "youtube#videoListResponse",
 "etag": "\"PMn2rAVTRiZHkX45qiqfcLZoTXM/C0A-YgKFiB4JY4gZcP7NsOPTWd0\"",
 "items": [
 ]
}

Using the equivalent objective C request, I have an assertion.

Assertion failure in -[GTLService parseObjectFromDataOfFetcher:](), 
/Users/tkormann/Documents/Projects/google-api-objectivec-client-read-only/Source
/Objects/GTLService.m:1145

I believe the assertion is not valid. I have no result and no error, that's 
true. But I should rather get either a specific NSError or a 
GTLYouTubeVideoListResponse with an empty 'items' list.

I can workaround the problem by always adding a valid videoId to each of my 
request or modify the actual code of GTLService.m but I would like to get your 
feedback on this issue prior to take any action.

What version of the product are you using? On what operating system?

current repository, youtube APIs 3.0 Exp. running iOS 6

Please provide any additional information below.

N/A

Original issue reported on code.google.com by thierry....@gmail.com on 27 Apr 2013 at 8:02

GoogleCodeExporter commented 9 years ago
Please use the library's http logging feature to provide a log of the request 
and response that led to the assertion, as well as the full description of the 
assertion.

https://code.google.com/p/google-api-objectivec-client/wiki/Introduction#Logging
_HTTP_Server_Traffic

Original comment by grobb...@google.com on 27 Apr 2013 at 10:14

GoogleCodeExporter commented 9 years ago
Here it is.

2013-04-28 16:53:57.618 YouTubeForKids[90712:cc0b] *** Assertion failure in 
-[GTLService parseObjectFromDataOfFetcher:](), 
/Users/tkormann/Documents/Wheepix/Projects/google-api-objectivec-client-read-onl
y/Source/Objects/GTLService.m:1145

Hope it helps.
Best Regards.

Original comment by thierry....@gmail.com on 28 Apr 2013 at 3:08

Attachments:

GoogleCodeExporter commented 9 years ago
It looks like the request has an invalid "fields" value. Try omitting that 
property.

Original comment by grobb...@google.com on 29 Apr 2013 at 11:20

GoogleCodeExporter commented 9 years ago
Hi,

Thank for your answer. Indeed, not setting the "fields" property to my 
GTLQueryYouTube fixes the assertion but now, as you know, in terms of data 
transfer it's far from optimal. 

Frankly, I still think there is an issue because given a bunch of video ids, I 
have no way to know whether or not I should avoid (or not) the "fields" 
property. In other words, there is no way to do a minimal query for a given set 
of video ids if you are not sure all of them still exist at a given point in 
time.

In fact, in my case, it would have even been more efficient to add a "fake" 
videoId to my list just to be sure to get something, rather than transferring 
all fields for all videos each time.

What do you recommend ? 

Thanks.

Original comment by thierry....@gmail.com on 30 Apr 2013 at 6:31

GoogleCodeExporter commented 9 years ago
The fields parameter is safe, as far as I'm aware. But it can be tricky. Your 
query had an invalid value for fields; try building the fields parameter up 
slowly to get the desired response.

I usually add fields only as a final optimization once my app's queries are 
working properly.

Original comment by grobb...@google.com on 1 May 2013 at 12:54

GoogleCodeExporter commented 9 years ago
Your answer makes me think I might not have been clear in my explanation. My 
query works perfectly fine. All the fields are valid. If I perform my query 
against a set of video ids that DO exist (not banned), everything works like a 
charm.

It's only when I am running the query against a set of video ids and ALL of 
them have been banned from YouTube, that I get the assertion failure.

For instance, running the query against 2 video ids, one that exists and one 
that has been banned, it works. But if for some reason, I only have banned 
videos in the query, I got the failure. This is why I do think there is an 
issue.

So, the "fields" property can not be safely used except if you are absolutely 
sure that at least one of the video id you specify using 
"queryForVideosListWithIdentifier" has not been banned from YouTube.

Here is a code snippet:

NSString *videoIds = @"hK8lUKt35vM"; // OK
NSString *videoIds = @"j7V_8QpnafA"; // KO video banned
NSString *videoIds = @"hK8lUKt35vM, j7V_8QpnafA"; // OK one video not banned
NSString *videoIds = @"j7V_8QpnafA, ylUWojqQRp0"; // KO both videos are banned

GTLQueryYouTube *gtlQuery = [GTLQueryYouTube 
queryForVideosListWithIdentifier:videoIds part:@"id,snippet,contentDetails"];
gtlQuery.fields = 
@"items(id,snippet/title,snippet/thumbnails/medium,contentDetails/duration)";
[service executeQuery:gtlQuery completionHandler:^(GTLServiceTicket *ticket,
                                            GTLYouTubeVideoListResponse *response,
                                            NSError *error) { }];

Original comment by thierry....@gmail.com on 1 May 2013 at 6:44

GoogleCodeExporter commented 9 years ago
The GTLService.m class does not currently have an assertion on line 1145, so 
I'm not certain what assert your code is hitting.

https://code.google.com/p/google-api-objectivec-client/source/browse/trunk/Sourc
e/Objects/GTLService.m#1145

Original comment by grobb...@google.com on 13 May 2013 at 11:42