Bug 1155995 - spacewalk-api returns a perl script instead of a boolean value
Summary: spacewalk-api returns a perl script instead of a boolean value
Keywords:
Status: CLOSED DEFERRED
Alias: None
Product: Red Hat Satellite 5
Classification: Red Hat
Component: API
Version: 570
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: ---
Assignee: Tomas Lestach
QA Contact: Red Hat Satellite QA List
URL:
Whiteboard:
: 1182925 (view as bug list)
Depends On:
Blocks: sat570-triage sat570-postga
TreeView+ depends on / blocked
 
Reported: 2014-10-23 11:12 UTC by Martin Korbel
Modified: 2018-04-09 11:25 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-04-09 11:25:48 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Martin Korbel 2014-10-23 11:12:53 UTC
Description of problem:
spacewalk-api returns this "bless( do{\(my $o = '0')}, 'Frontier::RPC2::Boolean')" instead of a boolean value.

Version-Release number of selected component (if applicable):
Sat5.7
Sat5.6

How reproducible:
100%

Steps to Reproduce:
> spacewalk-api --server localhost --user=admin --password=xxx user.listUsers  %session%

Actual results:
$result = [
            {
              'login_uc' => 'ADMIN',
              'id' => '1',
              'enabled' => bless( do{\(my $o = '1')}, 'Frontier::RPC2::Boolean' ),
              'login' => 'admin'
            },
            {
              'login_uc' => 'TEST',
              'id' => '3',
              'enabled' => bless( do{\(my $o = '1')}, 'Frontier::RPC2::Boolean' ),
              'login' => 'test'
            }
          ];

Expected results:
$result = [
            {
              'login_uc' => 'ADMIN',
              'id' => '1',
              'enabled' => true,
              'login' => 'admin'
            },
            {
              'login_uc' => 'TEST',
              'id' => '3',
              'enabled' => true,
              'login' => 'test'
            }
          ];
or

> spacewalk-api --server localhost --user=xxx --password=nimda user.getDetails  %session%  "admin"

Actual results:
$result = {
            'first_names' => 'Admin',
            'last_login_date' => '10/23/14 6:45:31 AM EDT',
            'org_name' => 'Red Hat SatTeam QA',
            'use_pam' => bless( do{\(my $o = '0')}, 'Frontier::RPC2::Boolean' ),
            'created_date' => '10/20/14 4:02:16 AM EDT',
            'last_name' => 'Admin',
            'email' => 'root@localhost',
            'org_id' => '1',
            'read_only' => bless( do{\(my $o = '0')}, 'Frontier::RPC2::Boolean' ),
            'errata_notification' => bless( do{\(my $o = '1')}, 'Frontier::RPC2::Boolean' ),
            'first_name' => 'Admin',
            'enabled' => bless( do{\(my $o = '1')}, 'Frontier::RPC2::Boolean' ),
            'prefix' => 'Mr.'
          };


Expected results:
$result = {
            'first_names' => 'Admin',
            'last_login_date' => '10/23/14 6:45:31 AM EDT',
            'org_name' => 'Red Hat SatTeam QA',
            'use_pam' => true,
            'created_date' => '10/20/14 4:02:16 AM EDT',
            'last_name' => 'Admin',
            'email' => 'root@localhost',
            'org_id' => '1',
            'read_only' => true,
            'errata_notification' => true,
            'first_name' => 'Admin',
            'enabled' => true,
            'prefix' => 'Mr.'
          };


Additional info:

Comment 1 Jan Hutař 2015-01-16 09:21:58 UTC
*** Bug 1182925 has been marked as a duplicate of this bug. ***

Comment 2 Martin Korbel 2015-02-18 07:04:43 UTC
The same case, but with date
Satellite-5.6.0-RHEL6-re20130927.0 (spacewalk-utils-2.0.2-22.el6sat)

'last_modified' => bless( do{\(my $o = '20131129T04:52:54')}, 'Frontier::RPC2::DateTime::ISO8601' ),

Reproducer:
spacewalk-api --server=localhost packages.findByNvrea %session% dracut %string:004% 336.el6_5.2 %string:% noarch
Enter username: admin
Enter your password: 
$result = [
            {
              'provider' => 'Red Hat Inc.',
              'arch_label' => 'noarch',
              'epoch' => '',
              'version' => '004',
              'last_modified' => bless( do{\(my $o = '20131129T04:52:54')}, 'Frontier::RPC2::DateTime::ISO8601' ),
              'name' => 'dracut',
              'path' => 'redhat/NULL/8ef/dracut/004-336.el6_5.2/noarch/8efa046b792fc482fea261d7ba594002454568a16beceeda74b24a95071f8900/dracut-004-336.el6_5.2.noarch.rpm',
              'release' => '336.el6_5.2',
              'id' => '13176'
            }
          ];

Comment 3 Jiri Precechtel 2016-04-15 14:19:09 UTC
Investigation showed this: 

Data types of values returned in API structures depend on their data type declaration (Java part). See API documentation for detailed information about input/output data types.

Perl doesn't support data types such as Boolean, DateTime... and there was not written automatic converter of these Frontier::RPC2 types to Perl types (numbers, strings).

There are of course ways in Perl, which allow us:
- to detect if the object reference ($ref) is blessed (Scalar::Util->blessed($ref)),
- to check if object reference is able to call method value() (UNIVERSAL::can($ref, "value")), 
- to return value of the blessed object reference ($ref->value())

But to do this additionally in returned data is very inefficient due to need of iteration through the whole data structure which can be theoretically huge.

Let me know if any questions please

Comment 5 Tomas Lestach 2016-11-03 16:51:19 UTC
I do not see any code changes, so I'm switching the BZ back to NEW.

Comment 6 Tomas Lestach 2018-04-09 11:25:48 UTC
We have re-reviewed this bug, as part of an ongoing effort to improve Satellite/Proxy feature and bug updates, review and backlog.

This is a low priority bug and has no currently open customer cases. While this bug may still valid, we do not see it being implemented prior to the EOL of the Satellite 5.x product. As such, this is being CLOSED DEFERRED. 

Closing now to help set customer expectations as early as possible. You are welcome to re-open this bug if needed.


Note You need to log in before you can comment on or make changes to this bug.