id, attachment.id, attachment.bug_id are returned as strings, not integers

RESOLVED FIXED

Status

()

RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: glob, Assigned: glob)

Tracking

Production
x86
Mac OS X

Details

Attachments

(1 attachment, 2 obsolete attachments)

(Assignee)

Description

5 years ago
id, attachment.id, attachment.bug_id are returned as strings, not integers:

   "attachments":
   [
       {
           "is_private": false,
           "ref": "http://bz/880669/bzapi/attachment/8340780",
           "bug_id": "880669",
           "last_change_time": "2014-06-17T08:09:10Z",
           "description": "[Bug 731601] rwasdf.eml",
           "size": 11,
           "attacher":
           {
               "real_name": "Byron Jones ‹:glob›",
               "name": "glob"
           },
           "content_type": "text/plain",
           "file_name": "file_880669.txt",
           "is_patch": false,
           "id": "8340780",
           "creation_time": "2014-06-17T08:09:10Z",
           "bug_ref": "http://bz/880669/bzapi/bug/880669",
           "is_obsolete": false
       }
   ],



here's data::dumper's view of $result just prior to json encoding in bugzilla/webservice/server/rest.pm:

   'attachments' => [
        {
            'is_private' => bless( do{\(my $o = 0)}, 'JSON::XS::Boolean' ),
            'ref' => 'http://bz/880669/bzapi/attachment/8340780',
            'bug_id' => 880669,
            'last_change_time' => '2014-06-17T08:09:10Z',
            'description' => '[Bug 731601] rwasdf.eml',
            'size' => 11,
            'attacher' => {
                'real_name' => "Byron Jones \x{2039}:glob\x{203a}",
                'name' => 'glob'
            },
            'content_type' => 'text/plain',
            'file_name' => 'file_880669.txt',
            'is_patch' => $VAR1->{'attachments'}[0]{'is_private'},
            'id' => 8340780,
            'creation_time' => '2014-06-17T08:09:10Z',
            'bug_ref' => 'http://bz/880669/bzapi/bug/880669',
            'is_obsolete' => $VAR1->{'attachments'}[0]{'is_private'}
        }
    ],

looks like we're doing the right thing.
(Assignee)

Updated

5 years ago
Assignee: nobody → glob
(Assignee)

Comment 1

5 years ago
Created attachment 8441388 [details] [diff] [review]
1026400_1.patch
Attachment #8441388 - Flags: review?(dkl)
(Assignee)

Comment 2

5 years ago
Comment on attachment 8441388 [details] [diff] [review]
1026400_1.patch

missed the top-level "id" field
Attachment #8441388 - Attachment is obsolete: true
Attachment #8441388 - Flags: review?(dkl)
(Assignee)

Comment 3

5 years ago
Created attachment 8441402 [details] [diff] [review]
1026400_2.patch
Attachment #8441402 - Flags: review?(dkl)
Comment on attachment 8441402 [details] [diff] [review]
1026400_2.patch

Review of attachment 8441402 [details] [diff] [review]:
-----------------------------------------------------------------

r=dkl with fix on commit

::: extensions/BzAPI/lib/Util.pm
@@ +120,4 @@
>          my $attachments = $rpc->attachments($attachment_params);
>  
>          my @fixed_attachments;
> +        foreach my $attachment (@{ $attachments->{bugs}->{int($data->{id})} }) {

Just use $bug->id in place of $data->{id} in the relevant places in fix_bug()
Attachment #8441402 - Flags: review?(dkl) → review+
Comment on attachment 8441402 [details] [diff] [review]
1026400_2.patch

Review of attachment 8441402 [details] [diff] [review]:
-----------------------------------------------------------------

You should be able to use $object in fix_attachment() actually so do that instead. Still r=dkl with fix on commit.

::: extensions/BzAPI/lib/Util.pm
@@ +120,4 @@
>          my $attachments = $rpc->attachments($attachment_params);
>  
>          my @fixed_attachments;
> +        foreach my $attachment (@{ $attachments->{bugs}->{int($data->{id})} }) {

Just use $bug->id in place of $data->{id} in the relevant places in fix_bug()

@@ +255,4 @@
>  
>      if ($data->{attachment_id} && $method ne 'Bug.search') {
>          $data->{attachment_ref} = $rpc->type('string', ref_urlbase() .
> +                                             "/attachment/" . int($data->{attachment_id}));

Actually it is also safe to just use $object->id here.

@@ +322,4 @@
>      }
>  
>      if (exists $data->{bug_id}) {
> +        $data->{bug_ref} = $rpc->type('string', ref_urlbase() . "/bug/" . int($data->{bug_id}));

$object->bug_id

@@ +347,4 @@
>          delete $data->{flags};
>      }
>  
> +    $data->{ref} = $rpc->type('string', ref_urlbase() . "/attachment/" . int($data->{id}));

$object->id
Duplicate of this bug: 1026498
(Assignee)

Comment 7

5 years ago
Created attachment 8441839 [details] [diff] [review]
1026400_3.patch
Attachment #8441402 - Attachment is obsolete: true
Attachment #8441839 - Flags: review?(dkl)
Comment on attachment 8441839 [details] [diff] [review]
1026400_3.patch

Review of attachment 8441839 [details] [diff] [review]:
-----------------------------------------------------------------

Works well. r=dkl
Attachment #8441839 - Flags: review?(dkl) → review+
(Assignee)

Comment 9

5 years ago
To ssh://gitolite3@git.mozilla.org/webtools/bmo/bugzilla.git
   324f00d..d83e1be  master -> master
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Probably any case where comments are included? _all is also affected:

https://bugzilla.mozilla.org/bzapi/bug?id=1026400&include_fields=_all
(Assignee)

Comment 12

5 years ago
thanks kohei.

please file new bugs for issues, instead of re-opening bugs that have been marked as fixed.
re-opening bugs makes tracking fixes difficult if a different person addresses the new issue.


thanks!
Status: REOPENED → RESOLVED
Last Resolved: 5 years ago5 years ago
Resolution: --- → FIXED
(Assignee)

Comment 13

5 years ago
(filed as bug 1027060)
You need to log in before you can comment on or make changes to this bug.