Bug#502312: libflickr-api-perl: Flickr API calls fail with 'API returned an invalid response' (line 111)

Mark Broadbent mbroadbent at messagelabs.com
Thu Oct 16 08:27:06 UTC 2008


Gunnar Wolf wrote:
> Seems like I doo need a test case for you reproducing this problem. I
> tried with:
>
> ------------------------------------------------------------
> #!/usr/bin/perl
> use YAML; 
> use Flickr::API;
> use Flickr::API::Request; 
>
> my ($key, $username, $api, $req, $res);
>
> $key = "this_is_not_my_real_key";
> $username = 'gunnarwolf';
>
> $api = Flickr::API->new({key => $key}); 
>
> $req = Flickr::API::Request->new({method => "flickr.people.findByUsername", 
> 				  args => {username => $username}}); 
>
> $res = $api->execute_request($req);
> print YAML::Dump $res;
> ------------------------------------------------------------
>
> And... The code failed to fail:
>   

 From my machine, with the same code (but different username and apikey)

Without patch:

$ perl -w tmp/test_api.pl
Use of uninitialized value in string ne at 
/usr/share/perl5/Flickr/API.pm line 111.
--- !!perl/hash:Flickr::API::Response
_content: 
"\x1f�\x08\0\0\0\0\0\0\x03�����Q(K-*��ϳU2�3PRH�K�O��K�U*-IӵPR����)*.P(.I,�U��V\x02�K�S�\x142Sl����M\r,�\x1d�\f��\x14��х��8�j�\x12sS��SKrRKJJ�Sm���\\\x106�\x06Zb�\x05\06`�h�\0\0\0"
_headers: !!perl/hash:HTTP::Headers
  cache-control: private
  client-date: 'Thu, 16 Oct 2008 08:20:10 GMT'
  client-peer: 68.142.214.24:80
  client-response-num: 1
  connection: close
  content-encoding: gzip
  content-length: 134
  content-type: text/xml; charset=utf-8
  date: 'Thu, 16 Oct 2008 08:20:10 GMT'
  p3p: 'policyref="http://p3p.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR 
CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi 
PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE GOV"'
  set-cookie:
    - 'cookie_l10n=en-us%3Buk; expires=Sunday, 16-Oct-11 08:20:10 GMT; 
path=/; domain=flickr.com'
    - 'cookie_intl=deleted; expires=Wednesday, 17-Oct-07 08:20:09 GMT; 
path=/; domain=flickr.com'
  vary: Accept-Encoding
_msg: OK
_protocol: HTTP/1.1
_rc: 200
_request: !!perl/hash:Flickr::API::Request
  _content: 
method=flickr.people.findByUsername&api_key=<apikey>&username=wetlettuce
  _headers: !!perl/hash:HTTP::Headers
    accept-encoding: gzip
    content-length: 96
    content-type: application/x-www-form-urlencoded
    user-agent: libwww-perl/5.813
  _method: POST
  _uri: !!perl/scalar:URI::http http://www.flickr.com/services/rest/
  api_args:
    api_key: <apikey>
    method: flickr.people.findByUsername
    username: wetlettuce
  api_method: flickr.people.findByUsername
  rest_uri: http://www.flickr.com/services/rest/
error_code: 0
error_message: API returned an invalid response
success: 0
tree: ~


With patch:

$ perl -w tmp/test_api.pl
--- !!perl/hash:Flickr::API::Response
_content: 
"\x1f�\x08\0\0\0\0\0\0\x03�����Q(K-*��ϳU2�3PRH�K�O��K�U*-IӵPR����)*.P(.I,�U��V\x02�K�S�\x142Sl����M\r,�\x1d�\f��\x14��х��8�j�\x12sS��SKrRKJJ�Sm���\\\x106�\x06Zb�\x05\06`�h�\0\0\0"
_headers: !!perl/hash:HTTP::Headers
  cache-control: private
  client-date: 'Thu, 16 Oct 2008 08:19:06 GMT'
  client-peer: 68.142.214.24:80
  client-response-num: 1
  connection: close
  content-encoding: gzip
  content-length: 134
  content-type: text/xml; charset=utf-8
  date: 'Thu, 16 Oct 2008 08:19:05 GMT'
  p3p: 'policyref="http://p3p.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR 
CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi 
PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE GOV"'
  set-cookie:
    - 'cookie_l10n=en-us%3Buk; expires=Sunday, 16-Oct-11 08:19:05 GMT; 
path=/; domain=flickr.com'
    - 'cookie_intl=deleted; expires=Wednesday, 17-Oct-07 08:19:04 GMT; 
path=/; domain=flickr.com'
  vary: Accept-Encoding
_msg: OK
_protocol: HTTP/1.1
_rc: 200
_request: !!perl/hash:Flickr::API::Request
  _content: 
method=flickr.people.findByUsername&api_key=<apikey>&username=wetlettuce
  _headers: !!perl/hash:HTTP::Headers
    accept-encoding: gzip
    content-length: 96
    content-type: application/x-www-form-urlencoded
    user-agent: libwww-perl/5.813
  _method: POST
  _uri: !!perl/scalar:URI::http http://www.flickr.com/services/rest/
  api_args:
    api_key: <apikey>
    method: flickr.people.findByUsername
    username: wetlettuce
  api_method: flickr.people.findByUsername
  rest_uri: http://www.flickr.com/services/rest/
error_code: 0
error_message: ''
success: 1
tree:
  attributes:
    stat: ok
  children:
    - content: "\n"
      type: data
    - attributes:
        id: 7775093 at N02
        nsid: 7775093 at N02
      children:
        - content: "\n\t"
          type: data
        - attributes: {}
          children:
            - content: wetlettuce
              type: data
          name: username
          type: tag
        - content: "\n"
          type: data
      name: user
      type: tag
    - content: "\n"
      type: data
  name: rsp
  type: tag



______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________





More information about the pkg-perl-maintainers mailing list